# BindingValue

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/data/struct-bindingvalue/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L86)

## Members

- [`new`](#function-new)
- [`unset`](#function-unset)
- [`do_nothing`](#function-do_nothing)
- [`binding_error`](#function-binding_error)
- [`binding_error_with_fallback`](#function-binding_error_with_fallback)
- [`data_validation_error`](#function-data_validation_error)
- [`data_validation_error_with_fallback`](#function-data_validation_error_with_fallback)
- [`has_value`](#function-has_value)
- [`has_error`](#function-has_error)
- [`value_type`](#function-value_type)
- [`value`](#function-value)
- [`error`](#function-error)
- [`into_option`](#function-into_option)
- [`get_value_or_default`](#function-get_value_or_default)
- [`with_value`](#function-with_value)
- [`map`](#function-map)
- [`to_optional`](#function-to_optional)
- [`get_value_or_default_option`](#function-get_value_or_default_option)
- [`get_value_or_default_as`](#function-get_value_or_default_as)
- [`get_value_or_default_as_or`](#function-get_value_or_default_as_or)
- [`to_untyped`](#function-to_untyped)
- [`from_untyped`](#function-from_untyped)
- [`from_untyped_with_type`](#function-from_untyped_with_type)

<a id="function-new"></a>

### new

```rust
fn new(value: T) -> Self
```

Creates a binding value holding a simple value.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L105)

<a id="function-unset"></a>

### unset

```rust
fn unset() -> Self
```

A binding value representing the unset state.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L111)

<a id="function-do_nothing"></a>

### do_nothing

```rust
fn do_nothing() -> Self
```

A binding value that is ignored by its target.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L117)

<a id="function-binding_error"></a>

### binding_error

```rust
fn binding_error(error: BindingError) -> Self
```

A binding error without a fallback value.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L122)

<a id="function-binding_error_with_fallback"></a>

### binding_error_with_fallback

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

A binding error with an optional fallback value.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L127)

<a id="function-data_validation_error"></a>

### data_validation_error

```rust
fn data_validation_error(error: BindingError) -> Self
```

A data validation error without a fallback value.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L137)

<a id="function-data_validation_error_with_fallback"></a>

### data_validation_error_with_fallback

```rust
fn data_validation_error_with_fallback(error: BindingError, fallback: Option<T>) -> Self
```

A data validation error with an optional fallback value.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L142)

<a id="function-has_value"></a>

### has_value

```rust
fn has_value(self: &Self) -> bool
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L153)

<a id="function-has_error"></a>

### has_error

```rust
fn has_error(self: &Self) -> bool
```

Whether the binding value carries an error.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L159)

<a id="function-value_type"></a>

### value_type

```rust
fn value_type(self: &Self) -> BindingValueType
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L164)

<a id="function-value"></a>

### value

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

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L170)

<a id="function-error"></a>

### error

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L175)

<a id="function-into_option"></a>

### into_option

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

Converts into the contained value, if any.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L181)

<a id="function-get_value_or_default"></a>

### get_value_or_default

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

Returns the value, or `default` if there is none.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L193)

<a id="function-with_value"></a>

### with_value

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L199)

<a id="function-map"></a>

### map

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

Maps the contained value, keeping the state.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L213)

<a id="function-to_optional"></a>

### to_optional

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L221)

<a id="function-get_value_or_default_option"></a>

### get_value_or_default_option

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L226)

<a id="function-get_value_or_default_as"></a>

### get_value_or_default_as

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L234)

<a id="function-get_value_or_default_as_or"></a>

### get_value_or_default_as_or

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L240)

<a id="function-to_untyped"></a>

### to_untyped

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L261)

<a id="function-from_untyped"></a>

### from_untyped

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L292)

<a id="function-from_untyped_with_type"></a>

### from_untyped_with_type

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/binding_value.rs#L303)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-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](/docs/0.5.0/api/).
