Skip to main content

BindingNotification

Struct BindingNotification 

Source
pub struct BindingNotification { /* private fields */ }
Expand description

Represents a binding notification that can be a valid binding value, or a binding or data validation error.

This type is very similar to BindingValue, but where BindingValue is used by typed bindings, this type is used to hold binding and data validation errors in untyped bindings.

A notification has reference semantics: it is shared as Rc<BindingNotification> (which converts to a BoxedValue holding the notification) and is modified in place.

Implementations§

Source§

impl BindingNotification

Source

pub fn null() -> Rc<BindingNotification>

A binding notification representing the null value.

Source

pub fn unset_value() -> Rc<BindingNotification>

A binding notification representing the unset value marker.

Source

pub fn new(value: Option<BoxedValue>) -> Self

Creates a binding notification for a binding value.

Source

pub fn with_error(error: BindingError, error_type: BindingErrorType) -> Self

Creates a binding notification for a binding error.

Panics if error_type is BindingErrorType::None.

Source

pub fn with_error_and_fallback( error: BindingError, error_type: BindingErrorType, fallback_value: Option<BoxedValue>, ) -> Self

Creates a binding notification for a binding error with a fallback value.

Panics if error_type is BindingErrorType::None.

Source

pub fn value(&self) -> Option<BoxedValue>

Gets the value that should be passed to the target when has_value is true.

If this is read when has_value is false then it returns the unset value marker.

Source

pub fn has_value(&self) -> bool

Gets a value indicating whether value should be pushed to the target.

Source

pub fn error(&self) -> Option<BindingError>

Gets the error that occurred on the source, if any.

Source

pub fn set_error(&self, error: Option<BindingError>)

Sets the error that occurred on the source.

Source

pub fn error_type(&self) -> BindingErrorType

Gets the type of error that error represents, if any.

Source

pub fn set_error_type(&self, error_type: BindingErrorType)

Sets the type of error that error represents.

Source

pub fn extract_value(o: Option<&BoxedValue>) -> Option<BoxedValue>

Gets a value from an untyped value that may be a binding notification.

If o is a binding notification then returns the binding notification’s value. If not, returns the value unchanged.

Source

pub fn update_value( o: Option<&BoxedValue>, value: Option<&BoxedValue>, ) -> Option<BoxedValue>

Updates the value of an untyped value that may be a binding notification.

If o is a binding notification then sets its value to value and returns the notification; otherwise returns value. If value is a binding notification then its value is extracted first.

Source

pub fn extract_error(o: Option<&BoxedValue>) -> Option<BoxedValue>

Gets an error from an untyped value that may be a binding notification.

If o is a binding notification then returns the binding notification’s error (boxed as a BindingError). If not, returns the value unchanged.

Source

pub fn add_error(&self, e: BindingError, error_type: BindingErrorType)

Adds an error to the binding notification.

Panics if error_type is BindingErrorType::None.

Source

pub fn clear_value(&self)

Removes the value and makes has_value return false.

Source

pub fn set_value(&self, value: Option<BoxedValue>)

Sets the value.

Trait Implementations§

Source§

impl Debug for BindingNotification

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for BindingNotification

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for BindingNotification

Source§

fn eq(&self, other: &Self) -> bool

Compares two binding notifications for equality.

1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

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> AnyValue for T
where T: PartialEq + 'static,

Source§

fn any_value_as_any(&self) -> &(dyn Any + 'static)

Source§

fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool

Source§

fn any_value_type_name(&self) -> &'static str

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.