Skip to main content

IAsyncDataTransferItem

Trait IAsyncDataTransferItem 

Source
pub trait IAsyncDataTransferItem {
    // Required methods
    fn formats(&self) -> Rc<[DataFormat]>;
    fn try_get_raw_async(
        &self,
        format: &DataFormat,
    ) -> LocalBoxFuture<Result<Option<Rc<dyn Any>>, ClipboardError>>;

    // Provided method
    fn try_formats(&self) -> Result<Rc<[DataFormat]>, ClipboardError> { ... }
}
Expand description

Represent an item inside a IAsyncDataTransfer. An item may support several formats and can return the value of a given format on demand.

See DataTransferItem for the mutable implementation.

Required Methods§

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.

Implementations of this method are expected to return a value matching the exact data type of the underlying DataFormatOf.

To retrieve a typed value, use AsyncDataTransferItemExtensions::try_get_value_async.

Provided Methods§

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.

formats has no way to report a failure (where the reference throws from the property, it panics); the asynchronous operations reading an item use this member instead, so that the failure reaches whoever awaits them. Items whose formats cannot fail keep the default.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§