Function wl_clipboard_rs::copy::prepare_copy_multi

source ·
pub fn prepare_copy_multi(
    options: Options,
    sources: Vec<MimeSource>,
) -> Result<PreparedCopy, Error>
Expand description

Prepares a data copy to the clipboard, offering multiple data sources.

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

If multiple sources specify the same MIME type, the first one is offered. If one of the MIME types is text, all automatically added plain text offers will fall back to the first source with a text MIME type.

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_multi(vec![MimeSource { source: Source::Bytes([1, 2, 3][..].into()),
                                              mime_type: MimeType::Autodetect },
                                 MimeSource { source: Source::Bytes([7, 8, 9][..].into()),
                                              mime_type: MimeType::Text }])?;
prepared_copy.serve()?;