FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    service_factory

    macro · ferroui-dependency-injection · v0.5.0

    macro_rules! service_factory
    

    Writes a factory and its validation metadata from typed constructor parameters.

    Parameters use required(T), optional(T), all(T), keyed(T, key), inherited(T), key() (the current Option<ServiceKey>), or typed_key(T) (a cloned key of type T, checked at activation). The body returns Rc<S>; use ObjectFactory::new for a fallible constructor.

    ## use ferroui_dependency_injection::*;
    ## use std::rc::Rc;
    let factory = service_factory!(String, |name: required(str)| Rc::new(name.to_string()));
    let descriptor = ServiceDescriptor::from_factory(ServiceLifetime::Transient, factory);
    

    View source

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.