cunarist / rinf

Rust for native business logic, Flutter for flexible and beautiful GUI
MIT License
1.88k stars 65 forks source link

send_signal_to_dart() function in rust code isn't generated when message contains enum and oneof fields in .protofile #306

Closed yeoupooh closed 6 months ago

yeoupooh commented 6 months ago

Report

send_signal_to_dart() function isn't generated when message contains enum and oneof fields in .proto file

Steps to Reproduce

  1. Basic rinf project setup.
  2. Write a new proto file (messages/enum_and_oneof.proto) as below.
    
    syntax = "proto3";
    package enum_and_oneof;

enum Kind { one = 0; two = 1; }

// [RINF:DART-SIGNAL] message SampleInput { Kind kind = 1; oneof oneof_input { string name = 2; int32 age = 3; } }

// [RINF:RUST-SIGNAL] message SampleOutput { Kind kind = 1; oneof oneof_input { string name = 2; int32 age = 3; } }

3. Run `rinf message`.
4. See enum_and_oneof.rs file in the native/hub/src/messages folder.

## System Information

Expected rust code is below:

... impl SampleInput { pub fn get_dart_signal_receiver() -> Receiver<DartSignal> { ... } }

impl SampleOutput { pub fn send_signal_to_dart(&self, blob: Option<Vec>) { send_rust_signal( 1, self.encode_to_vec(), blob ); } }


Actual rust code below:

... impl SampleInput { pub fn get_dart_signal_receiver() -> Receiver<DartSignal> { ... } }


As a workaround, it can be fixed by adding `;` before `// [RINF:RUST-SIGNAL]` in the proto file as below.

};

// [RINF:RUST-SIGNAL]