[][src]Function wl_clipboard_rs::utils::copy_data

pub fn copy_data(
    from_fd: Option<RawFd>,
    to_fd: RawFd,
    wait: bool
) -> Result<(), CopyDataError>

Copies data from one file to another.

This function assumes ownership of the passed file descriptors. That is, it closes them by itself. Use into_raw_fd().

If from_fd is None, the standard input is used as the data source.

If wait is true, this function returns after all data has been copied, otherwise it may return before all data has been copied.

Examples

use std::{fs::File, os::unix::io::IntoRawFd};
use wl_clipboard_rs::utils::copy_data;

let file = File::create("stdin-contents")?;

// Copy the standard input into the file.
copy_data(None, file.into_raw_fd(), true)?;