pub struct Clipboard { /* private fields */ }
Expand description
Manages access to the system clipboard for text-based copy and paste operations.
This struct acts as a handle to the platform’s native clipboard, abstracting away the
underlying implementation details. It is created using Clipboard::new()
.
All interactions are synchronous. For unsupported platforms (e.g., Android), operations are gracefully handled to prevent runtime errors.
Implementations§
Source§impl Clipboard
impl Clipboard
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new clipboard instance, initializing the connection to the system clipboard.
This method may fail if the system clipboard is unavailable, in which case it will panic.
§Panics
Panics if the clipboard provider cannot be initialized. This can happen in environments without a graphical user interface or due to system-level permission issues.
§Example
use tessera_ui::clipboard::Clipboard;
let clipboard = Clipboard::new();
Sourcepub fn get_text(&mut self) -> Option<String>
pub fn get_text(&mut self) -> Option<String>
Gets the current text content from the clipboard.
This method retrieves text from the clipboard. If the clipboard is empty, contains
non-text content, or an error occurs, it returns None
.
§Returns
Some(String)
if text is successfully retrieved from the clipboard.None
if the clipboard is empty, contains non-text data, or an error occurs.
§Example
use tessera_ui::clipboard::Clipboard;
let mut clipboard = Clipboard::new();
clipboard.set_text("Hello, Tessera!");
if let Some(text) = clipboard.get_text() {
println!("Retrieved from clipboard: {}", text);
} else {
println!("Clipboard was empty or contained non-text content.");
}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Clipboard
impl !RefUnwindSafe for Clipboard
impl Send for Clipboard
impl Sync for Clipboard
impl Unpin for Clipboard
impl !UnwindSafe for Clipboard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.