Skip to main content

IAsyncDataTransfer

Trait IAsyncDataTransfer 

Source
pub trait IAsyncDataTransfer: IDisposable {
    // Required methods
    fn formats(&self) -> Rc<[DataFormat]>;
    fn items(&self) -> Rc<[Rc<dyn IAsyncDataTransferItem>]>;

    // Provided methods
    fn try_formats(&self) -> Result<Rc<[DataFormat]>, ClipboardError> { ... }
    fn try_items(
        &self,
    ) -> Result<Rc<[Rc<dyn IAsyncDataTransferItem>]>, ClipboardError> { ... }
    fn as_data_transfer(self: Rc<Self>) -> Option<Rc<dyn IDataTransfer>> { ... }
}
Expand description

Represents an object providing a list of IAsyncDataTransferItem usable by the clipboard.

When an implementation of this interface is put into the clipboard using IClipboard::set_data_async, it must NOT be disposed by the caller. The system will dispose of it automatically when it becomes unused.

When an implementation of this interface is returned from the clipboard via IClipboard::try_get_data_async, it MUST be disposed by the caller.

See DataTransfer for the mutable implementation.

Required Methods§

Source

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

Gets the formats supported by the data transfer.

Source

fn items(&self) -> Rc<[Rc<dyn IAsyncDataTransferItem>]>

Gets a list of IAsyncDataTransferItem contained in this object.

Some platforms (such as Windows and X11) may only support a single data item for all formats except files.

Items returned by this property must stay valid until the data transfer is disposed.

Provided Methods§

Source

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

Gets the formats supported by the data transfer, 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 clipboard operations use this member instead, so that the failure reaches whoever awaits them. Data transfers whose formats cannot fail keep the default.

Source

fn try_items( &self, ) -> Result<Rc<[Rc<dyn IAsyncDataTransferItem>]>, ClipboardError>

Gets the items of the data transfer, or the failure of the platform that provides them. See try_formats.

Source

fn as_data_transfer(self: Rc<Self>) -> Option<Rc<dyn IDataTransfer>>

The object as a synchronous data transfer, if it also is one.

Implementations§

Source§

impl dyn IAsyncDataTransfer

Source

pub fn to_synchronous( self: Rc<Self>, log_area: &'static str, ) -> Rc<dyn IDataTransfer>

Returns the data transfer as a synchronous one: itself if it also implements IDataTransfer, a wrapper waiting for the values otherwise.

This is an implementation detail of the platform backends.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§