pub struct Content { /* private fields */ }Expand description
What to offer as the clipboard selection.
Each MIME type is either given data up front with data, or
only advertised with advertise. A paste of an
advertised type with no data raises a TransferRequest, which the owner
answers later. That is delayed rendering: the data is produced only if
something pastes it.
Implementations§
Source§impl Content
impl Content
Sourcepub fn new() -> Self
pub fn new() -> Self
Empty content.
Examples found in repository?
examples/copy.rs (line 11)
5fn main() -> lamco_data_control::Result<()> {
6 let text = std::env::args()
7 .nth(1)
8 .unwrap_or_else(|| "hello".to_owned());
9 let clipboard = DataControl::connect()?;
10 clipboard.set_selection(
11 Content::new()
12 .data("text/plain;charset=utf-8", text.clone())
13 .data("text/plain", text),
14 )?;
15 println!("clipboard set; press Ctrl-C to release it");
16 std::thread::park();
17 Ok(())
18}Sourcepub fn data(
self,
mime_type: impl Into<String>,
data: impl Into<Vec<u8>>,
) -> Self
pub fn data( self, mime_type: impl Into<String>, data: impl Into<Vec<u8>>, ) -> Self
Offer mime_type with its data.
Examples found in repository?
examples/copy.rs (line 12)
5fn main() -> lamco_data_control::Result<()> {
6 let text = std::env::args()
7 .nth(1)
8 .unwrap_or_else(|| "hello".to_owned());
9 let clipboard = DataControl::connect()?;
10 clipboard.set_selection(
11 Content::new()
12 .data("text/plain;charset=utf-8", text.clone())
13 .data("text/plain", text),
14 )?;
15 println!("clipboard set; press Ctrl-C to release it");
16 std::thread::park();
17 Ok(())
18}Sourcepub fn advertise(self, mime_type: impl Into<String>) -> Self
pub fn advertise(self, mime_type: impl Into<String>) -> Self
Offer mime_type without data; pastes of it raise a TransferRequest.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Content
impl RefUnwindSafe for Content
impl Send for Content
impl Sync for Content
impl Unpin for Content
impl UnsafeUnpin for Content
impl UnwindSafe for Content
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.