Skip to content

Multiple constructors are not available on Android; default constructor is lost! #2804

@pronebird

Description

@pronebird
#[uniffi::export(async_runtime = "tokio")]
impl NymEnvironment {
    #[uniffi::constructor]
    pub async fn new(
        cache_dir: PathBuf,
        network_name: &str,
    ) -> Result<Self, VpnError> {
        todo!()
    }

    #[uniffi::constructor]
    pub fn new_with_mainnet_fallback() -> Result<Self, VpnError> {
        todo!()
    }

    pub async fn __stub_to_keep_compiler_happy(&self) {
        // todo: remove after updating to uniffi 0.31
    }
}

When trying to create object using new initializer, I get nasty argument mismatch issue.

val env = NymEnvironment(storagePath, "some")

The default initailizer looks like some internal uniffi method that must not be exposed:

constructor(withHandle: UniffiWithHandle, handle: Long) {

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