Skip to main content

ferroui_base/input/platform/
i_clipboard_impl.rs

1use super::{ClipboardError, IFlushableClipboardImpl, IOwnedClipboardImpl};
2use crate::input::{IAsyncDataTransfer, LocalBoxFuture};
3use std::rc::Rc;
4
5/// Represents the platform implementation of the clipboard.
6///
7/// This is an implementation detail of the platform backends.
8///
9/// A failed operation resolves to a [`ClipboardError`] whose kind tells
10/// what happened (where the reference throws from the awaited task).
11pub trait IClipboardImpl {
12    /// Tries to get the data on the clipboard, if any.
13    fn try_get_data_async(&self) -> LocalBoxFuture<Result<Option<Rc<dyn IAsyncDataTransfer>>, ClipboardError>>;
14
15    /// Sets the data on the clipboard.
16    fn set_data_async(&self, data_transfer: Rc<dyn IAsyncDataTransfer>) -> LocalBoxFuture<Result<(), ClipboardError>>;
17
18    /// Clears the clipboard.
19    fn clear_async(&self) -> LocalBoxFuture<Result<(), ClipboardError>>;
20
21    /// The implementation as a flushable clipboard, if it is one.
22    fn as_flushable_clipboard_impl(&self) -> Option<&dyn IFlushableClipboardImpl> {
23        None
24    }
25
26    /// The implementation as an owned clipboard, if it is one.
27    fn as_owned_clipboard_impl(&self) -> Option<&dyn IOwnedClipboardImpl> {
28        None
29    }
30}