thlorenz / rid

Rust integrated Dart framework providing an easy way to build Flutter apps with Rust.
63 stars 4 forks source link

std::collections::*Map type support #4

Closed chertov closed 2 years ago

chertov commented 3 years ago

I found a field with Vec<_> type inside a model in the todo example. But std::collections::HashMap or std::collections::BTreeMap throws the error:

error:  [rid] Missing info for type HashMap. Specify it via on of:
...

It seems that the ffi implementation for the vectors is here: https://github.com/thlorenz/rid/blob/1b0214c37168ffb524b7ea2e59aae833350e9012/rid-ffi/src/lib.rs#L19

Is it possible to support std::collections maps?

thlorenz commented 3 years ago

Hi @chertov currently only Vec is supported, I'm planning to add HashMap and then more data types. I'm moving as fast as I can .. gonna address that once I got wasm support wrapped up.

You could work around this for now by converting to Vec before exposing to the model or similar. I'm also planning to allow you to [rid::exclude] fields you don't need on the Dart side, but also have not gotten to that yet.

It's all on my radar though.

chertov commented 3 years ago

@thlorenz Thanks, i am trying to add ffi codegen for *Map types like RidVec, but today it's quite difficult for me)

thlorenz commented 3 years ago

To support map types will take some effort as we'd also need to generate access methods, i.e. I did this for Vec namely len, get(idx), for map types there are more. As I said I'll try to address this as soon as I get wasm support to a decent stage.

If you wanna try to implement HashMap yourself though please LMK .. I'll try to help where I can.

thlorenz commented 3 years ago

@chertov see my comment in #5 regarding upcoming support for HashMap and similar.

chertov commented 3 years ago

@thlorenz thanks! The support for HashMap is very important feature! Awesome! I will try