pub struct MarkupDelegate { /* private fields */ }Expand description
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.
Implementations§
Source§impl MarkupDelegate
impl MarkupDelegate
pub fn new(f: impl Fn(&[MarkupValue]) -> MarkupValue + 'static) -> Self
Sourcepub fn for_method(
target: MarkupValue,
declaring_type: &'static MarkupType,
method: &'static MarkupMethod,
) -> Self
pub 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.
Sourcepub fn for_method_of_source(
target: &BoxedValue,
declaring_type: &'static MarkupType,
method: &'static MarkupMethod,
) -> Self
pub 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.
Sourcepub fn invoke(&self, arguments: &[MarkupValue]) -> MarkupValue
pub fn invoke(&self, arguments: &[MarkupValue]) -> MarkupValue
Calls the callback.
Sourcepub fn try_invoke(
&self,
arguments: &[MarkupValue],
) -> Result<MarkupValue, MarkupInvokeError>
pub fn try_invoke( &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.
Sourcepub fn target(&self) -> MarkupValue
pub fn target(&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.
Sourcepub fn is_target_alive(&self) -> bool
pub fn is_target_alive(&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.
Sourcepub fn method(&self) -> Option<&'static MarkupMethod>
pub fn method(&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.
Sourcepub fn declaring_type(&self) -> Option<&'static MarkupType>
pub fn declaring_type(&self) -> Option<&'static MarkupType>
The type whose metadata declares method.
Trait Implementations§
Source§impl Clone for MarkupDelegate
impl Clone for MarkupDelegate
Source§impl Debug for MarkupDelegate
impl Debug for MarkupDelegate
Source§impl Display for MarkupDelegate
The name of the delegate type, as the managed original prints a delegate
(System.Action, System.Action`1[System.Int32],
System.Func`2[System.Object,System.Boolean]) for the delegate of a
declared method; System.Delegate otherwise.
impl Display for MarkupDelegate
The name of the delegate type, as the managed original prints a delegate
(System.Action, System.Action`1[System.Int32],
System.Func`2[System.Object,System.Boolean]) for the delegate of a
declared method; System.Delegate otherwise.
Auto Trait Implementations§
impl !RefUnwindSafe for MarkupDelegate
impl !Send for MarkupDelegate
impl !Sync for MarkupDelegate
impl !UnwindSafe for MarkupDelegate
impl Freeze for MarkupDelegate
impl Unpin for MarkupDelegate
impl UnsafeUnpin for MarkupDelegate
Blanket Implementations§
Source§impl<T> AnyValue for Twhere
T: PartialEq + 'static,
impl<T> AnyValue for Twhere
T: PartialEq + 'static,
fn any_value_as_any(&self) -> &(dyn Any + 'static)
fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool
fn any_value_type_name(&self) -> &'static str
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more