Skip to main content

DataTransfer

Trait DataTransfer 

Source
pub trait DataTransfer: Any + Debug {
    // Required method
    fn for_each_available_type<'this>(
        &'this self,
        func: &mut dyn FnMut(&'this dyn TransferType) -> ControlFlow<()>,
    );

    // Provided methods
    fn available_types(&self) -> Vec<&dyn TransferType> { ... }
    fn has_type(&self, type_: &dyn TransferType) -> bool { ... }
}
Expand description

Metadata about a data transfer. This does not allow actually receiving data, as that is an asynchronous operation. To fetch the data from the source application, see ActiveEventLoop::fetch_data_transfer.

Required Methods§

Source

fn for_each_available_type<'this>( &'this self, func: &mut dyn FnMut(&'this dyn TransferType) -> ControlFlow<()>, )

Iterate over each type advertized by this DataTransfer. This is just a minor optimization, in most cases you should probably use has_type or available_types.

Provided Methods§

Source

fn available_types(&self) -> Vec<&dyn TransferType>

Display the list of all available types.

This is useful if more-complex type matching is required, but for most cases has_type should be used.

Source

fn has_type(&self, type_: &dyn TransferType) -> bool

Check if the supplied type is provided by this DataTransfer.

Supplying a TypeHint as the type is supported on all platforms, but if some platform-specific type is required then that platform’s implementation of TransferType can be used.

Implementations§

Source§

impl dyn DataTransfer + '_

Source

pub fn cast_ref<T: DataTransfer>(&self) -> Option<&T>

Downcast to the backend concrete type.

Returns None if the object was not from that backend.

Source

pub fn cast_mut<T: DataTransfer>(&mut self) -> Option<&mut T>

Mutable downcast to the backend concrete type.

Returns None if the object was not from that backend.

Source

pub fn cast<T: DataTransfer>(self: Box<Self>) -> Result<Box<T>, Box<Self>>

Owned downcast to the backend concrete type.

Returns Err with self if the object was not from that backend.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<T> DataTransfer for DataTransferSendBuilder<T>
where T: Debug + Send + 'static,