# TypeConverter

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-markup-xaml/converters/trait-typeconverter/

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

```rust
trait TypeConverter
```

Converts values of other types (text, above all) to the type the
converter is for, and back.

The defaults are the ones of the base class of the managed original: a
converter converts from nothing and to text.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/converters/type_converter.rs#L71)

## Members

- [`can_convert_from`](#function-can_convert_from)
- [`convert_from`](#function-convert_from)
- [`can_convert_to`](#function-can_convert_to)
- [`convert_to`](#function-convert_to)

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

### can_convert_from

```rust
fn can_convert_from(self: &Self, _context: Option<&Rc<dyn ITypeDescriptorContext>>, _source_type: ValueType) -> bool
```

Whether the converter can convert a value of `source_type` to its
type.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/converters/type_converter.rs#L74)

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

### convert_from

```rust
fn convert_from(self: &Self, _context: Option<&Rc<dyn ITypeDescriptorContext>>, _culture: Option<&CultureInfo>, value: Option<&BoxedValue>) -> Result<Option<BoxedValue>, XamlLoadError>
```

Converts `value` to the type of the converter.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/converters/type_converter.rs#L79)

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

### can_convert_to

```rust
fn can_convert_to(self: &Self, _context: Option<&Rc<dyn ITypeDescriptorContext>>, destination_type: ValueType) -> bool
```

Whether the converter can convert a value of its type to
`destination_type`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/converters/type_converter.rs#L93)

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

### convert_to

```rust
fn convert_to(self: &Self, _context: Option<&Rc<dyn ITypeDescriptorContext>>, _culture: Option<&CultureInfo>, value: Option<&BoxedValue>, destination_type: ValueType) -> Result<Option<BoxedValue>, XamlLoadError>
```

Converts `value` to `destination_type`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/converters/type_converter.rs#L98)

## Trait implementations

- [`TypeConverter`](/docs/0.5.0/api/ferroui-markup-xaml/converters/trait-typeconverter/)

## Availability

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