pub struct BindingValue<T> { /* private fields */ }Expand description
A value passed into a binding: a value, an “unset”/“do nothing” marker, or an error with an optional fallback value.
Implementations§
Source§impl<T> BindingValue<T>
impl<T> BindingValue<T>
Sourcepub fn do_nothing() -> Self
pub fn do_nothing() -> Self
A binding value that is ignored by its target.
Sourcepub fn binding_error(error: BindingError) -> Self
pub fn binding_error(error: BindingError) -> Self
A binding error without a fallback value.
Sourcepub fn binding_error_with_fallback(
error: BindingError,
fallback: Option<T>,
) -> Self
pub fn binding_error_with_fallback( error: BindingError, fallback: Option<T>, ) -> Self
A binding error with an optional fallback value.
Sourcepub fn data_validation_error(error: BindingError) -> Self
pub fn data_validation_error(error: BindingError) -> Self
A data validation error without a fallback value.
Sourcepub fn data_validation_error_with_fallback(
error: BindingError,
fallback: Option<T>,
) -> Self
pub fn data_validation_error_with_fallback( error: BindingError, fallback: Option<T>, ) -> Self
A data validation error with an optional fallback value.
pub fn value_type(&self) -> BindingValueType
pub fn error(&self) -> Option<&BindingError>
Sourcepub fn into_option(self) -> Option<T>
pub fn into_option(self) -> Option<T>
Converts into the contained value, if any.
Sourcepub fn get_value_or_default(self, default: T) -> T
pub fn get_value_or_default(self, default: T) -> T
Returns the value, or default if there is none.
Sourcepub fn with_value(self, value: T) -> Self
pub fn with_value(self, value: T) -> Self
Returns a binding value with the same error state and a new value. For error states this turns them into their “with fallback” variants.
Sourcepub fn map<U>(self, f: impl FnOnce(T) -> U) -> BindingValue<U>
pub fn map<U>(self, f: impl FnOnce(T) -> U) -> BindingValue<U>
Maps the contained value, keeping the state.
Source§impl<T: Clone> BindingValue<T>
impl<T: Clone> BindingValue<T>
Sourcepub fn to_optional(&self) -> Option<T>
pub fn to_optional(&self) -> Option<T>
Converts the binding value to an optional value: the value (or fallback value), if there is one.
Sourcepub fn get_value_or_default_option(&self) -> Option<T>
pub fn get_value_or_default_option(&self) -> Option<T>
Gets the value of the binding value if present, otherwise the default value: none.
Source§impl<T: Clone + 'static> BindingValue<T>
impl<T: Clone + 'static> BindingValue<T>
Sourcepub fn get_value_or_default_as<TResult: Clone + 'static>(
&self,
) -> Option<TResult>
pub fn get_value_or_default_as<TResult: Clone + 'static>( &self, ) -> Option<TResult>
Gets the value of the binding value if it is present and of type TResult, otherwise
the default value: none.
Sourcepub fn get_value_or_default_as_or<TResult: Clone + 'static>(
&self,
default_value: TResult,
) -> Option<TResult>
pub fn get_value_or_default_as_or<TResult: Clone + 'static>( &self, default_value: TResult, ) -> Option<TResult>
Gets the value of the binding value if it is present and of type TResult; none if it
is present and of another type; default_value if there is no value.
Source§impl<T: PropertyValue> BindingValue<T>
impl<T: PropertyValue> BindingValue<T>
Sourcepub fn to_untyped(&self) -> Option<BoxedValue>
pub fn to_untyped(&self) -> Option<BoxedValue>
Converts the value to untyped representation, using the unset and do-nothing markers
and BindingNotification where appropriate.
§Panics
Panics if the type of the binding value is none of the kinds BindingValueType
declares.
Sourcepub fn from_untyped(value: Option<&BoxedValue>) -> Self
pub fn from_untyped(value: Option<&BoxedValue>) -> Self
Creates a binding value from an untyped value: the unset or do-nothing marker, a
BindingNotification, or a value that converts implicitly to T.
Sourcepub fn from_untyped_with_type(
value: Option<&BoxedValue>,
target_type: ValueType,
) -> Self
pub fn from_untyped_with_type( value: Option<&BoxedValue>, target_type: ValueType, ) -> Self
Creates a binding value from an untyped value, converting the value to target_type.
A value that does not convert to target_type, or whose conversion is not a T,
gives a binding error. Null converts only to a target type that has a null value of
its own (a nullable form): T itself is never null here.
Trait Implementations§
Source§impl<T: Clone> Clone for BindingValue<T>
impl<T: Clone> Clone for BindingValue<T>
Source§impl<T: Debug> Debug for BindingValue<T>
impl<T: Debug> Debug for BindingValue<T>
Source§impl<T: Display> Display for BindingValue<T>
The text of the binding value: Error: <message> for an error, the text of the value, or
(null) without a value.
impl<T: Display> Display for BindingValue<T>
The text of the binding value: Error: <message> for an error, the text of the value, or
(null) without a value.
Source§impl<T> From<Option<T>> for BindingValue<T>
impl<T> From<Option<T>> for BindingValue<T>
Source§impl<T> From<T> for BindingValue<T>
impl<T> From<T> for BindingValue<T>
Source§impl<T: PartialEq> PartialEq for BindingValue<T>
impl<T: PartialEq> PartialEq for BindingValue<T>
impl<T: PartialEq> StructuralPartialEq for BindingValue<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for BindingValue<T>
impl<T> !Send for BindingValue<T>
impl<T> !Sync for BindingValue<T>
impl<T> !UnwindSafe for BindingValue<T>
impl<T> Freeze for BindingValue<T>
impl<T> Unpin for BindingValue<T>
impl<T> UnsafeUnpin for BindingValue<T>where
Option<T>: UnsafeUnpin,
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