[][src]Struct zio_sendfile::SendFile

pub struct SendFile {
    pub file: RawFd,
    pub count: usize,
    pub offset: off_t,
}

Abstraction for interacting with Linux's zero-copy I/O sendfile syscall.

let mut sendfile = SendFile::new(source, count)?;

loop {
    match sendfile.send(dest)? {
        0 => return Ok(()),
        _ => ()
    }
}

Fields

file: RawFdcount: usizeoffset: off_t

Methods

impl SendFile
[src]

pub fn new<F: AsRawFd>(file: &mut F, count: usize) -> Result<Self>
[src]

Set a file to be used as the sendfile source.

pub fn count(self, count: usize) -> Self
[src]

Set the number of bytes to write per call.

pub fn offset(self, offset: off_t) -> Self
[src]

Set the offset to begin copying bytes from.

pub fn send<F: AsRawFd>(&mut self, to: &mut F) -> Result<u64>
[src]

Begin copying from the the sendfile to the destination file.

  • This will write up to self.count amount of bytes at a time.
  • The self.offset value is updated by the syscall on return.

Auto Trait Implementations

impl Send for SendFile

impl Sync for SendFile

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]