# DataTransferItem

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/input/struct-datatransferitem/

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

```rust
struct DataTransferItem
```

A mutable implementation of [`IDataTransferItem`](/docs/0.5.0/api/ferroui-base/input/trait-idatatransferitem/) and
[`IAsyncDataTransferItem`](/docs/0.5.0/api/ferroui-base/input/trait-iasyncdatatransferitem/). This type also provides several functions to
easily create a `DataTransferItem` for common usages.

While it also implements [`IAsyncDataTransferItem`](/docs/0.5.0/api/ferroui-base/input/trait-iasyncdatatransferitem/), this type always
returns data synchronously. For advanced usages, consider implementing
[`IAsyncDataTransferItem`](/docs/0.5.0/api/ferroui-base/input/trait-iasyncdatatransferitem/) directly.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/data_transfer_item.rs#L31)

## Members

- [`new`](#function-new)
- [`formats`](#function-formats)
- [`contains`](#function-contains)
- [`try_get_raw`](#function-try_get_raw)
- [`try_get_value`](#function-try_get_value)
- [`set`](#function-set)
- [`set_with`](#function-set_with)
- [`set_text`](#function-set_text)
- [`set_file`](#function-set_file)
- [`set_bitmap`](#function-set_bitmap)
- [`create`](#function-create)
- [`create_with`](#function-create_with)
- [`create_text`](#function-create_text)
- [`create_file`](#function-create_file)

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

### new

```rust
fn new() -> Rc<DataTransferItem>
```

Creates an item without any format.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/data_transfer_item.rs#L40)

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

### formats

```rust
fn formats(self: &Self) -> Rc<[DataFormat]>
```

Gets the formats supported by this item.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/data_transfer_item.rs#L45)

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

### contains

```rust
fn contains(self: &Self, format: &DataFormat) -> bool
```

Gets whether the item supports a specific format.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/data_transfer_item.rs#L56)

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

### try_get_raw

```rust
fn try_get_raw(self: &Self, format: &DataFormat) -> Option<Rc<dyn Any>>
```

Tries to get a value for a given format. Returns `None` if the
format is not supported.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/data_transfer_item.rs#L62)

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

### try_get_value

```rust
fn try_get_value<T: Clone + 'static>(self: &Self, format: &DataFormatOf<T>) -> Option<T>
```

Tries to get a typed value for a given format.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/data_transfer_item.rs#L69)

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

### set

```rust
fn set<T: 'static>(self: &Self, format: &DataFormatOf<T>, value: Option<T>)
```

Sets the value for a given format.

If `value` is `None`, the format won't be part of the item.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/data_transfer_item.rs#L80)

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

### set_with

```rust
fn set_with<T: 'static>(self: &Self, format: &DataFormatOf<T>, get_value: impl Fn() -> Option<T> + 'static)
```

Sets a value created on demand for a given format.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/data_transfer_item.rs#L88)

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

### set_text

```rust
fn set_text(self: &Self, value: Option<&str>)
```

Sets the value for the `DataFormat::text` format.

If `value` is `None`, the format won't be part of the item.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/data_transfer_item.rs#L126)

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

### set_file

```rust
fn set_file(self: &Self, value: Option<Rc<dyn IStorageItem>>)
```

Sets the value for the `DataFormat::file` format.

If `value` is `None`, the format won't be part of the item.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/data_transfer_item.rs#L133)

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

### set_bitmap

```rust
fn set_bitmap(self: &Self, value: Option<Rc<Bitmap>>)
```

Sets the value for the `DataFormat::bitmap` format.

If `value` is `None`, the format won't be part of the item.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/data_transfer_item.rs#L140)

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

### create

```rust
fn create<T: 'static>(format: &DataFormatOf<T>, value: Option<T>) -> Rc<DataTransferItem>
```

Creates a new item for a single format with a given value.

If `value` is `None`, the format won't be part of the item.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/data_transfer_item.rs#L147)

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

### create_with

```rust
fn create_with<T: 'static>(format: &DataFormatOf<T>, get_value: impl Fn() -> Option<T> + 'static) -> Rc<DataTransferItem>
```

Creates a new item for a single format with a given value created on
demand.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/data_transfer_item.rs#L155)

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

### create_text

```rust
fn create_text(value: Option<&str>) -> Rc<DataTransferItem>
```

Creates a new item with `DataFormat::text` as a single format.

If `value` is `None`, the format won't be part of the item.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/data_transfer_item.rs#L167)

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

### create_file

```rust
fn create_file(value: Option<Rc<dyn IStorageItem>>) -> Rc<DataTransferItem>
```

Creates a new item with `DataFormat::file` as a single format.

If `value` is `None`, the format won't be part of the item.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/input/data_transfer_item.rs#L174)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`AsyncDataTransferItemExtensions`](/docs/0.5.0/api/ferroui-base/input/trait-asyncdatatransferitemextensions/)
- [`DataTransferItemExtensions`](/docs/0.5.0/api/ferroui-base/input/trait-datatransferitemextensions/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ErasedDestructor`
- `IntoEither`
- [`IDataTransferItem`](/docs/0.5.0/api/ferroui-base/input/trait-idatatransferitem/)
- [`IAsyncDataTransferItem`](/docs/0.5.0/api/ferroui-base/input/trait-iasyncdatatransferitem/)

## Availability

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