Skip to content

Deriving ToJava for Java Enum to Rust Enums  #194

@gavinclarke1

Description

@gavinclarke1

Description

I am enquiring if it is possible to currently use ToJava or any other means to map a Rust variant enum to a Java enum. In the examples I see a rust enum being mapped to differing java classes using ToRust but 1-1 to a java enum.

For example I am looking to achieve the following:

Java

public enum ClassificationIdKey {
    A,
    B,
    C
}

Rust

This code could be easily updated in whatever means to represent the java enum

#[derive(duchess::toJava)]
pub enum ClassificationIdKey {
    A,
    B, 
    C
}

When attempting this conversion it asks me to define the java.class name for each enum value.

If this is not possible, is is possible to allow you to implement the ToJava trait yourself, to set how the value is translated ? I am asking here as https://duchess-rs.github.io/duchess/derive.html points to a empty file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions