BindingValue
struct · ferroui-base · v0.5.0
struct BindingValue<T>
A value passed into a binding: a value, an "unset"/"do nothing" marker, or an error with an optional fallback value.
Members
newunsetdo_nothingbinding_errorbinding_error_with_fallbackdata_validation_errordata_validation_error_with_fallbackhas_valuehas_errorvalue_typevalueerrorinto_optionget_value_or_defaultwith_valuemapto_optionalget_value_or_default_optionget_value_or_default_asget_value_or_default_as_orto_untypedfrom_untypedfrom_untyped_with_type
new
fn new(value: T) -> Self
Creates a binding value holding a simple value.
unset
fn unset() -> Self
A binding value representing the unset state.
do_nothing
fn do_nothing() -> Self
A binding value that is ignored by its target.
binding_error
fn binding_error(error: BindingError) -> Self
A binding error without a fallback value.
binding_error_with_fallback
fn binding_error_with_fallback(error: BindingError, fallback: Option<T>) -> Self
A binding error with an optional fallback value.
data_validation_error
fn data_validation_error(error: BindingError) -> Self
A data validation error without a fallback value.
data_validation_error_with_fallback
fn data_validation_error_with_fallback(error: BindingError, fallback: Option<T>) -> Self
A data validation error with an optional fallback value.
has_value
fn has_value(self: &Self) -> bool
Whether the binding value carries a value (or fallback value).
has_error
fn has_error(self: &Self) -> bool
Whether the binding value carries an error.
value_type
fn value_type(self: &Self) -> BindingValueType
value
fn value(self: &Self) -> &T
The value. Panics if there is none, see has_value.
error
fn error(self: &Self) -> Option<&BindingError>
into_option
fn into_option(self: Self) -> Option<T>
Converts into the contained value, if any.
get_value_or_default
fn get_value_or_default(self: Self, default: T) -> T
Returns the value, or default if there is none.
with_value
fn with_value(self: 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.
map
fn map<U>(self: Self, f: impl FnOnce(T) -> U) -> BindingValue<U>
Maps the contained value, keeping the state.
to_optional
fn to_optional(self: &Self) -> Option<T>
Converts the binding value to an optional value: the value (or fallback value), if there is one.
get_value_or_default_option
fn get_value_or_default_option(self: &Self) -> Option<T>
Gets the value of the binding value if present, otherwise the default value: none.
get_value_or_default_as
fn get_value_or_default_as<TResult: Clone + 'static>(self: &Self) -> Option<TResult>
Gets the value of the binding value if it is present and of type TResult, otherwise
the default value: none.
get_value_or_default_as_or
fn get_value_or_default_as_or<TResult: Clone + 'static>(self: &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.
to_untyped
fn to_untyped(self: &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.
from_untyped
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.
from_untyped_with_type
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
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafePropertyValueAnyValueClassDefaultsBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>From<never>TryInto<U>TryFrom<U>AnyToOwnedToStringErasedDestructorIntoEitherCloneDebugStructuralPartialEqPartialEqDisplayFrom<Option<T>>
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.