Skip to main content

DataTransferItem

Struct DataTransferItem 

Source
pub struct DataTransferItem { /* private fields */ }
Expand description

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.

Implementations§

Source§

impl DataTransferItem

Source

pub fn new() -> Rc<DataTransferItem>

Creates an item without any format.

Source

pub fn formats(&self) -> Rc<[DataFormat]>

Gets the formats supported by this item.

Source

pub fn contains(&self, format: &DataFormat) -> bool

Gets whether the item supports a specific format.

Source

pub fn try_get_raw(&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

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

Tries to get a typed value for a given format.

Source

pub fn set<T: 'static>(&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

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

Sets a value created on demand for a given format.

Source

pub fn set_text(&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

pub fn set_file(&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

pub fn set_bitmap(&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

pub 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

pub 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

pub 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

pub 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§

Source§

impl IAsyncDataTransferItem for DataTransferItem

Source§

fn formats(&self) -> Rc<[DataFormat]>

Gets the formats supported by this item.
Source§

fn try_get_raw_async( &self, format: &DataFormat, ) -> LocalBoxFuture<Result<Option<Rc<dyn Any>>, ClipboardError>>

Tries to get a value for a given format. The future resolves to None if the format is not supported, and to an error if the platform providing the value fails. Read more
Source§

fn try_formats(&self) -> Result<Rc<[DataFormat]>, ClipboardError>

Gets the formats supported by this item, or the failure of the platform that provides them. Read more
Source§

impl IDataTransferItem for DataTransferItem

Source§

fn formats(&self) -> Rc<[DataFormat]>

Gets the formats supported by this item.
Source§

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

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<I> AsyncDataTransferItemExtensions for I

Source§

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

Gets whether the item supports a specific format.
Source§

fn try_contains(&self, format: &DataFormat) -> Result<bool, ClipboardError>

Gets whether the item supports a specific format, or the failure of the platform that provides the formats of the item.
Source§

fn try_get_value_async<T: Clone + 'static>( &self, format: &DataFormatOf<T>, ) -> LocalBoxFuture<Result<Option<T>, ClipboardError>>

Tries to get a value for a given format from the item. The future resolves to None if the format is not supported, and to an error if the platform providing the value fails.
Source§

fn try_get_text_async( &self, ) -> LocalBoxFuture<Result<Option<String>, ClipboardError>>

Returns a text, if available, from the item.
Source§

fn try_get_bitmap_async( &self, ) -> LocalBoxFuture<Result<Option<Rc<Bitmap>>, ClipboardError>>

Returns a bitmap, if available, from the item.
Source§

fn try_get_file_async( &self, ) -> LocalBoxFuture<Result<Option<Rc<dyn IStorageItem>>, ClipboardError>>

Returns a file (or folder), if available, from the item. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
Source§

impl<I> DataTransferItemExtensions for I

Source§

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

Gets whether the item supports a specific format.
Source§

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

Tries to get a value for a given format from the item. Returns None if the format is not supported.
Source§

fn try_get_text(&self) -> Option<String>

Returns a text, if available, from the item.
Source§

fn try_get_bitmap(&self) -> Option<Rc<Bitmap>>

Returns a bitmap, if available, from the item.
Source§

fn try_get_file(&self) -> Option<Rc<dyn IStorageItem>>

Returns a file (or folder), if available, from the item. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.