FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    MarkupDelegate

    struct · ferroui-base · v0.5.0

    struct MarkupDelegate
    

    An untyped callback (the equivalent of a delegate instance): what an event subscription declared in metadata receives as its handler, and what a binding to a method produces.

    View source

    Members

    new

    fn new(f: impl Fn(&[MarkupValue]) -> MarkupValue + 'static) -> Self
    

    Source

    for_method

    fn for_method(target: MarkupValue, declaring_type: &'static MarkupType, method: &'static MarkupMethod) -> Self
    

    The delegate of a method declared in metadata, bound to target (method.CreateDelegate(type, target) in the managed original). target is the instance for an instance method and ignored for a static one; declaring_type is the type whose metadata lists method. The delegate keeps the target alive.

    invoke calls the method with the arguments given (after the instance) and discards a failure; try_invoke reports it.

    Source

    for_method_of_source

    fn for_method_of_source(target: &BoxedValue, declaring_type: &'static MarkupType, method: &'static MarkupMethod) -> Self
    

    The delegate of a method of a binding source: what a binding to a method reads. As for_method, but the delegate does not keep target alive (a source that is a reference; a plain value is held as a binding holds it, by value). Once the target is gone target is None, is_target_alive is false and invoking the delegate does nothing.

    Deviation (DEVIATIONS.md, Bindings): the managed delegate has its target strongly, and so has the command made from it. A template that binds a command of one of its parts to a method of the templated control is a cycle there (the control, its template, the part, the value of its command property, the control), which the collector frees; without one it would never be freed.

    Source

    invoke

    fn invoke(self: &Self, arguments: &[MarkupValue]) -> MarkupValue
    

    Calls the callback.

    Source

    try_invoke

    fn try_invoke(self: &Self, arguments: &[MarkupValue]) -> Result<MarkupValue, MarkupInvokeError>
    

    Calls the callback. For the delegate of a declared method (for_method) a failure of the call (wrong arguments, a failing member) is returned.

    Source

    target

    fn target(self: &Self) -> MarkupValue
    

    The instance the delegate of a declared instance method is bound to (the Target of the managed original). None for a static method and for a delegate that was not created from a declared method.

    Source

    is_target_alive

    fn is_target_alive(self: &Self) -> bool
    

    Whether the delegate can still call what it was created for: false once the target of the delegate of a binding source (for_method_of_source) is gone.

    Source

    method

    fn method(self: &Self) -> Option<&'static MarkupMethod>
    

    The declared method the delegate was created from (the Method of the managed original), if it was created with for_method.

    Source

    declaring_type

    fn declaring_type(self: &Self) -> Option<&'static MarkupType>
    

    The type whose metadata declares method.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • PropertyValue
    • AnyValue
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • ToString
    • ErasedDestructor
    • IntoEither
    • Clone
    • PartialEq
    • Debug
    • Display

    Availability

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