FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    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.

    View source

    Members

    new

    fn new(value: T) -> Self
    

    Creates a binding value holding a simple value.

    Source

    unset

    fn unset() -> Self
    

    A binding value representing the unset state.

    Source

    do_nothing

    fn do_nothing() -> Self
    

    A binding value that is ignored by its target.

    Source

    binding_error

    fn binding_error(error: BindingError) -> Self
    

    A binding error without a fallback value.

    Source

    binding_error_with_fallback

    fn binding_error_with_fallback(error: BindingError, fallback: Option<T>) -> Self
    

    A binding error with an optional fallback value.

    Source

    data_validation_error

    fn data_validation_error(error: BindingError) -> Self
    

    A data validation error without a fallback value.

    Source

    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.

    Source

    has_value

    fn has_value(self: &Self) -> bool
    

    Whether the binding value carries a value (or fallback value).

    Source

    has_error

    fn has_error(self: &Self) -> bool
    

    Whether the binding value carries an error.

    Source

    value_type

    fn value_type(self: &Self) -> BindingValueType
    

    Source

    value

    fn value(self: &Self) -> &T
    

    The value. Panics if there is none, see has_value.

    Source

    error

    fn error(self: &Self) -> Option<&BindingError>
    

    Source

    into_option

    fn into_option(self: Self) -> Option<T>
    

    Converts into the contained value, if any.

    Source

    get_value_or_default

    fn get_value_or_default(self: Self, default: T) -> T
    

    Returns the value, or default if there is none.

    Source

    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.

    Source

    map

    fn map<U>(self: Self, f: impl FnOnce(T) -> U) -> BindingValue<U>
    

    Maps the contained value, keeping the state.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • PropertyValue
    • AnyValue
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • From<never>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • ToString
    • ErasedDestructor
    • IntoEither
    • Clone
    • Debug
    • StructuralPartialEq
    • PartialEq
    • Display
    • From<Option<T>>

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.