---
source: crates/alef-backend-dart/tests/snapshot_test.rs
expression: "&file.content"
---
// Generated by alef. Do not edit by hand.
#![allow(unused_variables, unreachable_code)]
#![allow(
    clippy::map_identity,
    clippy::let_and_return,
    clippy::collapsible_match,
    clippy::manual_flatten,
    clippy::too_many_arguments,
    clippy::unit_arg,
    clippy::type_complexity,
    clippy::useless_conversion,
)]
mod frb_generated;
use flutter_rust_bridge::frb;
pub use flutter_rust_bridge::DartFnFuture;

/// A demo configuration struct.
#[frb(mirror(Config))]
pub struct Config {
    pub value: i64,
    pub label: String,
    pub tag: Option<String>,
}

/// Processing status.
#[frb(mirror(Status), unignore)]
pub enum Status {
    /// Active state.
    Active,
    /// Inactive state.
    Inactive,
}

/// Errors emitted by demo operations.
#[frb(mirror(DemoError), unignore)]
pub enum DemoError {
    /// Input validation failed.
    InvalidInput,
    /// Processing encountered an error.
    ProcessingFailed,
}

// From<SourceT> conversions for bridge return types.

impl From<demo::Config> for Config {
    fn from(v: demo::Config) -> Self {
        Config {
            value: v.value as _,
            label: v.label.into(),
            tag: v.tag.flatten().map(|s| s.into()),
        }
    }
}

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

// From<T> for SourceT conversions (mirror-to-core direction).
// Used in bridge functions for types with sanitized fields, and by
// nested conversions within those types.

/// Process input and return a result.
pub fn process(input: String, count: i64) -> Result<String, String> {
    demo::process(input, count as u32).map(|v| v.to_string()).map_err(|e| e.to_string())
}

// `create_<Type>_from_json` helpers — deserialize a JSON string into a mirror type.
