Open NightBlaze opened 1 month ago
IMHO generics is not supported yet - thus it may not be able to be used currently. However, is good to have it implemented! Feel free to PR, alternatively I may work on it later, but since this is a nontrivial new feature, I cannot guarantee it will be done very soon.
Got it. Thanks.
I'll be glad to create a PR but don't have enough proficient in Rust and Dart :(
You are welcome and it's OK!
Not sure is it an issue or I do something wrong.
Demo project available here: https://github.com/NightBlaze/generics-frb
I use stateful architecture with the next structure for each screen:
Dart part:
screen.dart
file https://github.com/NightBlaze/generics-frb/blob/main/lib/root_screen.dart ) • it's just UI without logic which calls Rust code and receive responses via stream.Rust part:
Logic (
screen_name_logic.rs
file https://github.com/NightBlaze/generics-frb/blob/main/rust/src/api/screens/root_screen/root_screen_logic.rs ) • it's exposesScreenNameLogic
struct without any public fields, just functions. • it implements interior mutability pattern • it holdsview_model_sink: Option<StreamSink<ScreenNameViewModel>>
field • it holds a state of a screenState (
screen_name_state.rs
file https://github.com/NightBlaze/generics-frb/blob/main/rust/src/api/screens/root_screen/root_screen_state.rs ) • it's a simple struct. • it has apub(crate) fn render(&self) -> ScreenNameViewModel
to create a view model. Technically it'sInto
trait but I decided to not use it.ViewModel (
screen_name_view_model.rs
file https://github.com/NightBlaze/generics-frb/blob/main/rust/src/api/screens/root_screen/root_screen_view_models.rs ) • it's a simple struct without any logic.So every
ScreenNameLogic
has a function to render state like this one:and it's a good candidate to make it generics ( https://github.com/NightBlaze/generics-frb/blob/main/rust/src/api/screens/renderer.rs )
flutter_rust_bridge_codegen generate
works without any errors but there is an error infrb_generated.rs
I tried to make all
pub
but still have the error.So my questions are:
Renderable
trait for another struct State?I use frb v. 2.1.0