ferroui_base/input/i_data_transfer.rs
1use super::{DataFormat, IAsyncDataTransfer, IDataTransferItem};
2use crate::reactive::IDisposable;
3use std::rc::Rc;
4
5/// Represents an object providing a list of [`IDataTransferItem`] usable
6/// during a drag and drop operation.
7///
8/// When an implementation of this interface is used as a drag source using
9/// [`DragDrop::do_drag_drop_async`](super::DragDrop::do_drag_drop_async),
10/// it must NOT be disposed by the caller. The system will dispose of it
11/// automatically when the drag operation completes.
12///
13/// See [`DataTransfer`](super::DataTransfer) for the mutable
14/// implementation.
15pub trait IDataTransfer: IDisposable {
16 /// Gets the formats supported by the data transfer.
17 fn formats(&self) -> Rc<[DataFormat]>;
18
19 /// Gets a list of [`IDataTransferItem`] contained in this object.
20 ///
21 /// Some platforms (such as Windows and X11) may only support a single
22 /// data item for all formats except files.
23 ///
24 /// Items returned by this property must stay valid until the data
25 /// transfer is disposed.
26 fn items(&self) -> Rc<[Rc<dyn IDataTransferItem>]>;
27
28 /// The object as an asynchronous data transfer, if it also is one.
29 fn as_async_data_transfer(self: Rc<Self>) -> Option<Rc<dyn IAsyncDataTransfer>> {
30 None
31 }
32}