Skip to main content

ModelTypeBuilder

Struct ModelTypeBuilder 

Source
pub struct ModelTypeBuilder<T: PartialEq + 'static> { /* private fields */ }
Expand description

Declares the binding metadata of model type T.

Implementations§

Source§

impl<T: PartialEq + 'static> ModelTypeBuilder<T>

Source

pub fn notify_property_changed(self) -> Self

Declares that the type raises property change notifications.

Source

pub fn notify_data_error_info(self) -> Self

Declares that the type reports validation errors.

Source

pub fn list(self) -> Self
where T: IBindableList,

Declares that the type is a list that binding indexers can index.

Source

pub fn indexer(self) -> Self

Declares that the type has an indexer that binding indexers can use (Items[key]).

Source

pub fn array(self) -> Self
where T: IBindableArray,

Declares that the type is an array: a fixed-size collection accessed with integer indexes, one per dimension.

Source

pub fn notify_collection_changed(self) -> Self

Declares that the type raises collection change notifications.

Source

pub fn command(self) -> Self
where T: ICommand,

Declares that the type is a command, so that instances can be bound to command properties.

Source

pub fn property_info(self, property: Rc<dyn IPropertyInfo>) -> Self

Declares a property from a ready-made description.

Source

pub fn read_only<K: PropertyKind>( self, name: &str, get: impl Fn(&T) -> K::Typed + 'static, ) -> Self

Declares a read-only property. K states how the typed value maps to an untyped binding value, see PropertyKind.

Source

pub fn property<K: PropertyKind>( self, name: &str, get: impl Fn(&T) -> K::Typed + 'static, set: impl Fn(&T, K::Typed) + 'static, ) -> Self

Declares a read-write property.

Source

pub fn validated_property<K: PropertyKind>( self, name: &str, get: impl Fn(&T) -> K::Typed + 'static, set: impl Fn(&T, K::Typed) -> Result<(), BindingError> + 'static, ) -> Self

Declares a read-write property whose setter can reject a value. The error surfaces as a data validation error on bindings that have data validation enabled (the equivalent of throwing from a setter).

Source

pub fn method( self, name: &str, execute: impl Fn(&T, Option<&BoxedValue>) + 'static, ) -> Self

Declares a method that bindings can use as a command.

Source

pub fn method_with_can_execute( self, name: &str, execute: impl Fn(&T, Option<&BoxedValue>) + 'static, can_execute: impl Fn(&T, Option<&BoxedValue>) -> bool + 'static, depends_on: &[&str], ) -> Self

Declares a method with a “can execute” predicate that is re-queried when one of the properties named in depends_on changes.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.