Skip to content

allow frb mirror on concrete generic enum #2252

@acul009

Description

@acul009

Is your feature request related to a problem? Please describe.
I have a struct like this:

pub enum RemoteLiveData<T> {
    Unavailable,
    Pending,
    Ready(T),
}

I can also already define methods and it works fine:

#[frb(external)]
impl RemoteLiveData<RealtimeStatus> {
    pub fn is_pending(&self) -> bool {}
}

obviously frb can't yet handle full generics by itself, but I'd like to propose an intermediate.

Describe the solution you'd like
When frb encounters a return value like RemoteLiveData<RealtimeStatus> it monomorphisizes (what a freaking word) that type into RemoteLiveDataRealtimeStatus which is totaly fine and works great.

All I'd like to do is define a mirror for the concrete type of generic enum:

#[frb(non_opaque, mirror(RemoteLiveData<RealtimeStatus>))]
pub enum _RemoteLiveDataRealtimeStatus {
    Unavailable,
    Pending,
    Ready(RealtimeStatus),
}

Unfortunately this does not register as a mirrored type and just produces this comment:

// These types are ignored because they are not used by any `pub` functions:  `_RemoteLiveDataRealtimeStatus`

Describe alternatives you've considered
I've tried experimenting with wrappers and additional helper functions, but that get's out of hand quickly.
These mirrors on the other hand might be easy to generate using macros.

I've tried digging through the generator codebase to find which parts to change, but that seems to be way beyond my skill level at the moment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestwontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions