DataTransferItem
struct · ferroui-base · v0.5.0
struct DataTransferItem
A mutable implementation of IDataTransferItem and
IAsyncDataTransferItem. This type also provides several functions to
easily create a DataTransferItem for common usages.
While it also implements IAsyncDataTransferItem, this type always
returns data synchronously. For advanced usages, consider implementing
IAsyncDataTransferItem directly.
Members
newformatscontainstry_get_rawtry_get_valuesetset_withset_textset_fileset_bitmapcreatecreate_withcreate_textcreate_file
new
fn new() -> Rc<DataTransferItem>
Creates an item without any format.
formats
fn formats(self: &Self) -> Rc<[DataFormat]>
Gets the formats supported by this item.
contains
fn contains(self: &Self, format: &DataFormat) -> bool
Gets whether the item supports a specific format.
try_get_raw
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.
try_get_value
fn try_get_value<T: Clone + 'static>(self: &Self, format: &DataFormatOf<T>) -> Option<T>
Tries to get a typed value for a given format.
set
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.
set_with
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.
set_text
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.
set_file
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.
set_bitmap
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.
create
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.
create_with
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.
create_text
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.
create_file
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.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeAsyncDataTransferItemExtensionsDataTransferItemExtensionsClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyErasedDestructorIntoEitherIDataTransferItemIAsyncDataTransferItem
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.