fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.

Home Page:https://fzyzcjy.github.io/flutter_rust_bridge/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

For the type `pub struct A(pub B)` in Dart, use either `B` or `class A { final B value; }`.

iota9star opened this issue · comments

Is your feature request related to a problem? Please describe.
Just like the title says.
image

Looks reasonable! (I prefer the latter, since that's partially why people need newtype pattern). Feel free to PR, alternatively I will work on it in the next batch.

Is your feature request related to a problem? Please describe. Just like the title says. image

I have a similar issue:

@sealed
class FrSerialport extends RustOpaque {
  FrSerialport.dcoDecode(List<dynamic> wire)
      : super.dcoDecode(wire, _kStaticData);

  FrSerialport.sseDecode(int ptr, int externalSizeOnNative)
      : super.sseDecode(ptr, externalSizeOnNative, _kStaticData);

  static final _kStaticData = RustArcStaticData(
    rustArcIncrementStrongCount:
        RustLib.instance.api.rust_arc_increment_strong_count_FrSerialport,
    rustArcDecrementStrongCount:
        RustLib.instance.api.rust_arc_decrement_strong_count_FrSerialport,
    rustArcDecrementStrongCountPtr:
        RustLib.instance.api.rust_arc_decrement_strong_count_FrSerialportPtr,
  );

  static Future<FrSerialport> connect(
          {required String portName, dynamic hint}) =>
      RustLib.instance.api.frSerialportConnect(portName: portName, hint: hint);
      
  static Future<List<String>> getPorts({dynamic hint}) =>
      RustLib.instance.api.frSerialportGetPorts(hint: hint);

  Future<String> get({dynamic hint}) => RustLib.instance.api.frSerialportGet(
        that: this,
      );
  Future<void> send({required String data, dynamic hint}) =>
      RustLib.instance.api.frSerialportSend(
        that: this,
        data: data,
      );
}

In the above code, i can only access FrSerialport.connect and FrSerialport.getPorts but i can't access FrSerialport.get and FrSerialport.send.
I noticed it's all the methods that take in self as an argument are the ones i can't access.

Please, what is the way out of this issue. is there a solution to it already?

In the above code, i can only access FrSerialport.connect and FrSerialport.getPorts but i can't access FrSerialport.get and FrSerialport.send.
I noticed it's all the methods that take in self as an argument are the ones i can't access.

@Zacchaeus-Oluwole Hi, could you please create a separate issue and provide a minimal reproducible sample? Without the corresponding Rust code it is not easy to say what is going on :/

Alright,I will do that. Thank you

You are welcome

It seems that this is already supported. For example, in the tests:

image

image

Thus, I guess your question is "why it is opaque instead of non-opaque". Thus try to put #[frb(non_opaque)] on it.

Feel free to open if this does not solve your question!