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
impl BindingNotification
Sourcepub fn null() -> Rc<BindingNotification>
pub fn null() -> Rc<BindingNotification>
A binding notification representing the null value.
Sourcepub fn unset_value() -> Rc<BindingNotification>
pub fn unset_value() -> Rc<BindingNotification>
A binding notification representing the unset value marker.
Sourcepub fn new(value: Option<BoxedValue>) -> Self
pub fn new(value: Option<BoxedValue>) -> Self
Creates a binding notification for a binding value.
Sourcepub fn with_error(error: BindingError, error_type: BindingErrorType) -> Self
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.
Sourcepub fn with_error_and_fallback(
error: BindingError,
error_type: BindingErrorType,
fallback_value: Option<BoxedValue>,
) -> Self
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.
Sourcepub fn value(&self) -> Option<BoxedValue>
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.
Sourcepub fn has_value(&self) -> bool
pub fn has_value(&self) -> bool
Gets a value indicating whether value should be
pushed to the target.
Sourcepub fn error(&self) -> Option<BindingError>
pub fn error(&self) -> Option<BindingError>
Gets the error that occurred on the source, if any.
Sourcepub fn set_error(&self, error: Option<BindingError>)
pub fn set_error(&self, error: Option<BindingError>)
Sets the error that occurred on the source.
Sourcepub fn error_type(&self) -> BindingErrorType
pub fn error_type(&self) -> BindingErrorType
Gets the type of error that error represents, if any.
Sourcepub fn set_error_type(&self, error_type: BindingErrorType)
pub fn set_error_type(&self, error_type: BindingErrorType)
Sets the type of error that error represents.
Sourcepub fn extract_value(o: Option<&BoxedValue>) -> Option<BoxedValue>
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.
Sourcepub fn update_value(
o: Option<&BoxedValue>,
value: Option<&BoxedValue>,
) -> Option<BoxedValue>
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.
Sourcepub fn extract_error(o: Option<&BoxedValue>) -> Option<BoxedValue>
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.
Sourcepub fn add_error(&self, e: BindingError, error_type: BindingErrorType)
pub fn add_error(&self, e: BindingError, error_type: BindingErrorType)
Adds an error to the binding notification.
Panics if error_type is BindingErrorType::None.
Sourcepub fn clear_value(&self)
pub fn clear_value(&self)
Sourcepub fn set_value(&self, value: Option<BoxedValue>)
pub fn set_value(&self, value: Option<BoxedValue>)
Sets the value.
Trait Implementations§
Source§impl Debug for BindingNotification
impl Debug for BindingNotification
Source§impl Display for BindingNotification
impl Display for BindingNotification
Auto Trait Implementations§
impl !Freeze for BindingNotification
impl !RefUnwindSafe for BindingNotification
impl !Send for BindingNotification
impl !Sync for BindingNotification
impl !UnwindSafe for BindingNotification
impl Unpin for BindingNotification
impl UnsafeUnpin for BindingNotification
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