-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The right way to send a large buffer Vec<u8> from rust to dart #5
Comments
seems
only vectors of struct |
the problem is here: rid/rid-macro-impl/src/model/dart.rs Line 72 in 0a5f33a
my dirty little hack for Vec: DartType::Vec(inner) => {
let raw = if inner == "u8" {
""
} else {
"Raw"
};
format!(
"{dart_ffi}.Pointer<{ffigen_bind}.Vec_{raw}{ty}>",
dart_ffi = DART_FFI,
ffigen_bind = FFI_GEN_BIND,
raw = raw,
ty = inner
)
}, it might be better to do this with recursively nested types, but I haven't learned enough of the structure of the codegen yet |
I'm sorry you're running into these problems, but I'm happy you're digging in and are encountering work arounds. The whole If you want to share the code you're working on so I can use it to extract test cases to fix please do. |
I fixed a lot of field access cases for vecs. Which means a vec attached to a struct like the store can now be sent if the item is a primitive or String as well as the cases that worked before. For exported functions not all of those are supported yet since that is a different case as the returned Vec is no longer accessible from the Rust side and also needs to be cleaned up from Dart. I'm looking into adding support for HashMap and similar data types yet. In order to address the case you need first could you please provide a small sample of code that you would like to work with Rid @chertov ? |
I haven't tried the updated version yet and I don't fully understand the concept of my app using rid. This will change a lot of things in my app. My library is used by several applications. It looks like I can't do several different states in the same code right now. With cfg! it is possible with cargo features, but in one application you cannot have several states now. |
See #13 which adds lots more types you can return from an export. |
For example, in my use case i need to connect to backend via websockets from rust.
I start the connection process in Store::create() function in a new thread, i want to load jpeg pictures and render them with flutter. I can't create
#[rid::reply] enum Replay
with variant containsVec<u8>
fielderror: For replies with a single field it needs to be a u64 or String, i.e. 'Started(u64) or Started(String)'
to use it like here https://github.com/thlorenz/rid-examples/blob/49de40408064833823aad08dbd4e03b928ff3265/flutter/todo_cubit/lib/blocs/cubit/todo_cubit.dart#L31
And
#[rid::replay]
can't be a struct:error: rid::reply attribute can only be applied to enums
I can keep data in the state, but it's not very convenient.. i need to send 'update' message and get replay back to clear the buffer in the store. How to do this right way? Is this possible today? Thanks!
The text was updated successfully, but these errors were encountered: