---
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, missing_docs)]
#![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,
    clippy::new_without_default,
)]


/// 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 Config;
        fn value(&self) -> i32;
        fn label(&self) -> String;
        fn tag(&self) -> String;
    }

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

    extern "Rust" {
        fn process(input: String, count: u32) -> Result<String, String>;
    }

    extern "Rust" {
        // Phantom Vec<T> functions: swift-bridge-build must emit the full Vec support
        // C ABI symbols (__swift_bridge__$Vec_T$new, drop, push, pop, get, get_mut, as_ptr, len)
        // which the auto-generated Swift Vec<T> conformances reference.
        //
        // swift-bridge 0.1.59 only emits these when Vec<T> appears as a return type
        // in an extern block. Without these phantom functions, Swift linker fails when
        // trying to construct or manipulate Vec<T> of opaque types.
        //
        // These declarations are paired with phantom_impl functions below the bridge module.
        fn __alef_phantom_vec_config() -> Vec<Config>;
        fn __alef_phantom_vec_status() -> Vec<Status>;
    }

}

#[doc(hidden)]
pub fn __alef_phantom_vec_config() -> Vec<Config> { Vec::new() }
#[doc(hidden)]
pub fn __alef_phantom_vec_status() -> Vec<Status> { Vec::new() }

pub struct Config(pub demo::Config);
impl Config {
    pub fn value(&self) -> i32 {
        self.0.value.clone()
    }
    pub fn label(&self) -> String {
        format!("{:?}", &self.0.label)
    }
    pub fn tag(&self) -> String {
        serde_json::to_string(&self.0.tag).expect("serializable tag")
    }
}

pub enum Status {
    Active,
    Inactive,
}

impl From<demo::Status> for Status {
    fn from(val: demo::Status) -> Self {
        match val {
            demo::Status::Active => Self::Active,
            demo::Status::Inactive => Self::Inactive,
        }
    }
}

impl Status {
    pub fn to_string(&self) -> String {
        match self {
            Self::Active => "Active".to_string(),
            Self::Inactive => "Inactive".to_string(),
        }
    }
}

pub fn process(input: String, count: u32) -> Result<String, String> {
    demo::process(input, count).map_err(|e| e.to_string()).map(|s| s.to_string())
}
