cunarist / rinf

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

Can't use `import` in proto files #222

Closed NightBlaze closed 9 months ago

NightBlaze commented 11 months ago

Report

Can't use import in proto files.

If I use import "feed_view_model.proto"; syntax then got error:

-> % rinf message
Building package executable... 
Built rinf:rinf.
Verifying `protoc-gen-prost` for Rust. This might take a while if there are new updates to be installed.
feed.proto:9:14: "FeedItemViewModel" is not defined.

If I use import "./feed_view_model.proto"; syntax then got error:

-> % rinf message
Building package executable... 
Built rinf:rinf.
Verifying `protoc-gen-prost` for Rust. This might take a while if there are new updates to be installed.
./feed_view_model.proto: Backslashes, consecutive slashes, ".", or ".." are not allowed in the virtual path
feed.proto:3:1: Import "./feed_view_model.proto" was not found or had errors.
feed.proto:9:14: "FeedItemViewModel" is not defined.

proto

Steps to Reproduce

Create two proto files and import one file into another.

System Information

-> % rustc --version
rustc 1.73.0 (cc66ad468 2023-10-03)

-> % protoc --version
libprotoc 25.0

-> % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.0, on macOS 14.1.1 23B81 darwin-x64, locale ru-RU)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.84.2)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!
temeddix commented 11 months ago

Hi @NightBlaze , thank you for your report :)

Right now, Rinf doesn't consider imports being used in those files. I'll try to fix it and make a new version soon.

NightBlaze commented 11 months ago

Thanks @temeddix! It will be very convenient for a domain modeling.

temeddix commented 9 months ago

Sorry for being late, I was focusing on other issues inside Rinf.

Starting from Rinf 5.3, you will be able to use import statements in Protobuf files, like this:

// messages/fractal.proto

syntax = "proto3";
package fractal;

import 'counter_number.proto';

message StateSignal {
  int32 id = 1;
  double current_scale = 2;
  counter_number.SampleSchema something = 3;
}

P.S. If you're coming from Rinf 4, you have to run rinf template again.