FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    ObjectType

    trait · ferroui-base · v0.5.0

    trait ObjectType: StaticType + Upcast<crate::FerroObject> + Sized
    

    Implemented by every class.

    Safety

    Implemented only by ferro_class! (and by hand for the root class). Implementors guarantee that:

    • Self is #[repr(C)]-compatible with Parent at offset zero, i.e. a pointer to Self is a valid pointer to every class in its ancestor chain;
    • VTable likewise starts with Parent::VTable at offset zero;
    • values of Self are only created through instantiate (class structs have a private base field and construct-style constructors that are only meaningful inside instantiate).

    View source

    Members

    Parent

    type Parent: ObjectType
    

    The base class. The root class is its own parent.

    Source

    IDENTITY

    const IDENTITY: &'static TypeIdentity
    

    The identity of the class (TypeIdentity): what is::<Self>(), cast::<Self>() and downcast_ref::<Self>() compare. A type check names this rather than StaticType::TYPE, so it does not keep the initialisation, the constructor and the markup metadata of the class in the executable (#612).

    Source

    register_class

    fn register_class()
    

    The static initialisation of the class. The first call on a thread, after doing the same for the base class:

    1. makes the type known by name (TypeInfo::find);
    2. registers the handle type Ref<Self> and the interface handles the class declares (ferro_class_info!) with the untyped value conversions;
    3. registers the properties of the class in declaration order (ferro_properties!);
    4. runs the static constructor of the class (ClassDefaults::static_constructor).

    Later calls only read a thread-local flag.

    Generated by ferro_class!. Called by instantiate, so a class that has an instance on the thread is initialised, and through TypeInfo::ensure_class_init by property accessors and the property registry, for classes that have none.

    Source

    Trait implementations

    Availability

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