# IBindingTypeConverter

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactiveui/binding/bindings/trait-ibindingtypeconverter/

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

```rust
trait IBindingTypeConverter
```

Converts the values of one type to another for the bindings (`IBindingTypeConverter`).

A converter names its source and target types; `BindingTypeConverterRegistry` finds it by that
pair, and of several converters of one pair the one with the highest affinity wins. Most
converters derive from the base `BindingTypeConverter`, which writes this trait from a typed
conversion; a converter that handles its input itself implements this trait directly.

Values cross this API type-erased: the input is a `&dyn Any` (`None` stands for upstream's
`null`), and a converted value is an `Rc<dyn Any>` holding a value of `to_type`.




[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/i_binding_type_converter.rs#L96)

## Members

- [`from_type`](#function-from_type)
- [`to_type`](#function-to_type)
- [`get_affinity_for_objects`](#function-get_affinity_for_objects)
- [`try_convert_typed`](#function-try_convert_typed)

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

### from_type

```rust
fn from_type(self: &Self) -> ConverterType
```

The type this converter converts from (`FromType`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/i_binding_type_converter.rs#L98)

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

### to_type

```rust
fn to_type(self: &Self) -> ConverterType
```

The type this converter converts to (`ToType`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/i_binding_type_converter.rs#L101)

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

### get_affinity_for_objects

```rust
fn get_affinity_for_objects(self: &Self) -> i32
```

How well this converter converts from `from_type` to
`to_type`: a positive score when it can, where a higher score wins; zero or
less when it cannot (`GetAffinityForObjects`). The built-in converters score
`BindingAffinity::DEFAULT_INTERNAL_TYPE_CONVERTER`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/i_binding_type_converter.rs#L107)

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

### try_convert_typed

```rust
fn try_convert_typed(self: &Self, from: Option<&dyn Any>, conversion_hint: Option<&dyn Any>) -> Option<Rc<dyn Any>>
```

Converts `from` (`None` for upstream's `null`), with an optional `conversion_hint` (a
format, a width, a value to compare with: what the converter makes of it), and returns the
converted value, or `None` when `from` is not a value of `from_type` or
cannot be converted (`TryConvertTyped`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/i_binding_type_converter.rs#L113)

## Trait implementations

- [`IBindingTypeConverter`](/docs/0.5.0/api/ferroui-reactiveui/binding/bindings/trait-ibindingtypeconverter/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
