Skip to content
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

Open
quetool opened this issue Jan 15, 2025 · 1 comment
Open

RustOpaqueInterface on Enums #2498

quetool opened this issue Jan 15, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@quetool
Copy link

quetool commented Jan 15, 2025

Hello! I have the following rust code inside a crate:

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)]
#[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)]
#[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)]
#[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)]
#[serde(rename_all = "UPPERCASE", tag = "status")]
pub enum StatusResponse {
    Pending(StatusResponsePending),
    Completed(StatusResponseCompleted),
    Error(StatusResponseError),
}

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

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<StatusResponse>>
abstract class StatusResponse implements RustOpaqueInterface {}

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<StatusResponseCompleted>>
abstract class StatusResponseCompleted implements RustOpaqueInterface {}

Can you please advise on how to overcome this?

@quetool quetool added the enhancement New feature or request label Jan 15, 2025
Copy link

welcome bot commented Jan 15, 2025

Hi! Thanks for opening your first issue here! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants
@quetool and others