---
source: tests/backends_swift_snapshot_test.rs
expression: "&file.content"
---
// Generated by alef. Do not edit by hand.

#![allow(unused_variables, unreachable_code, unreachable_patterns)]
#![allow(
    clippy::collapsible_if,
    clippy::collapsible_match,
    clippy::needless_borrows_for_generic_args,
    clippy::field_reassign_with_default,
    clippy::too_many_arguments,
    clippy::clone_on_copy,
    clippy::unnecessary_cast,
    clippy::manual_flatten,
    clippy::match_single_binding,
    clippy::redundant_closure,
    clippy::useless_conversion,
    clippy::inherent_to_string,
)]


/// Process-wide tokio runtime shared across every swift-bridge async wrapper.
///
/// alef-emitted; see shims.rs for the rationale (orphaned reqwest connection
/// pools when each call creates and drops its own current-thread runtime).
fn __alef_tokio_runtime() -> &'static ::tokio::runtime::Runtime {
    use std::sync::OnceLock;
    static RT: OnceLock<::tokio::runtime::Runtime> = OnceLock::new();
    RT.get_or_init(|| {
        ::tokio::runtime::Builder::new_multi_thread()
            .enable_all()
            .build()
            .expect("build process-wide alef tokio runtime")
    })
}

#[swift_bridge::bridge]
mod ffi {
    extern "Rust" {
        type Data;
        #[swift_bridge(init)]
        fn new(value: i32) -> Data;
        fn value(&self) -> i32;
    }

    extern "Rust" {
        type Result;
        fn to_string(&self) -> String;
    }

}


pub struct Data(pub demo::Data);
impl Data {
    pub fn new(value: i32) -> Data {
        Data(demo::Data {
            value,
        })
    }
    pub fn value(&self) -> i32 {
        self.0.value.clone()
    }
}

pub enum Result {
    Success,
    Error,
}

impl From<demo::Result> for Result {
    fn from(val: demo::Result) -> Self {
        match val {
            demo::Result::Success { .. } => Self::Success,
            demo::Result::Error { .. } => Self::Error,
        }
    }
}

impl Result {
    pub fn to_string(&self) -> String {
        match self {
            Self::Success => "Success".to_string(),
            Self::Error => "Error".to_string(),
        }
    }
}
