-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RustOpaqueInterface on Enums #2498
Comments
Hi! Thanks for opening your first issue here! 😄 |
Hi, could you please try |
Hello, thanks for the reply! [features]
full = ["frb"]
frb = ["dep:flutter_rust_bridge_codegen", "dep:flutter_rust_bridge"]
[build-dependencies]
flutter_rust_bridge_codegen = { workspace = true, optional = true }
[dependencies]
flutter_rust_bridge = { workspace = true, optional = true } Then we have this Cargo.toml file (again, hot the whole) on the second crate which is also a flutter package: [features]
frb_expand = []
[build-dependencies]
flutter_rust_bridge_codegen.workspace = true
[dependencies]
yttrium = { path = "../../yttrium" }
flutter_rust_bridge.workspace = true So, in the previous rust file I shared, which is inside So this is the resulted file: use {
relay_rpc::domain::ProjectId,
serde::{Deserialize, Serialize},
};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "uniffi", derive(uniffi_macros::Record))]
#[cfg_attr(feature = "frb", frb(non_opaque))] // <--- frb macro
#[serde(rename_all = "camelCase")]
pub struct StatusResponsePending {
pub created_at: u64,
/// Polling interval in ms for the client
pub check_in: u64,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "uniffi", derive(uniffi_macros::Record))]
#[cfg_attr(feature = "frb", frb(non_opaque))] // <--- frb macro
#[serde(rename_all = "camelCase")]
pub struct StatusResponseCompleted {
pub created_at: u64,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "uniffi", derive(uniffi_macros::Record))]
#[cfg_attr(feature = "frb", frb(non_opaque))] // <--- frb macro
#[serde(rename_all = "camelCase")]
pub struct StatusResponseError {
pub created_at: u64,
pub error: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "uniffi", derive(uniffi_macros::Enum))]
#[cfg_attr(feature = "frb", frb(non_opaque))] // <--- frb macro
#[serde(rename_all = "UPPERCASE", tag = "status")]
pub enum StatusResponse {
Pending(StatusResponsePending),
Completed(StatusResponseCompleted),
Error(StatusResponseError),
} But still after running |
Oh I see. It would be great if things are kept in a single crate. When using multi crates, i.e. some structs are "third party structs", you may need https://cjycode.com/flutter_rust_bridge/guides/third-party |
Hello! I have the following rust code inside a crate:
And I'm depending from this crate to create a fluter package, but not matter what I do, when I generate the code I get these enums translated to Rust opaque trypes
Can you please advise on how to overcome this?
The text was updated successfully, but these errors were encountered: