Function wl_clipboard_rs::copy::prepare_copy

source ·
pub fn prepare_copy(
    options: Options,
    source: Source,
    mime_type: MimeType,
) -> Result<PreparedCopy, Error>
Expand description

Prepares a data copy to the clipboard.

The data is copied from source and offered in the mime_type MIME type. See Options for customizing the behavior of this operation.

This function can be used instead of copy() when it’s desirable to separately prepare the copy operation, handle any errors that this may produce, and then start the serving loop, potentially past a fork (which is how wl-copy uses it). It is meant to be used in the foreground mode and does not spawn any threads.

§Panics

Panics if foreground is false.

§Examples

use wl_clipboard_rs::copy::{MimeSource, MimeType, Options, Source};

let mut opts = Options::new();
opts.foreground(true);
let prepared_copy = opts.prepare_copy(Source::Bytes([1, 2, 3][..].into()),
                                      MimeType::Autodetect)?;
prepared_copy.serve()?;