Destination

Trait Destination 

Source
pub trait Destination: AsyncWrite + Send {
    // Required methods
    fn write_file<O: FileOpener>(
        &mut self,
        file: &mut Sendfile<O>,
    ) -> Result<usize, Error>;
    fn poll_write(&self) -> Async<()>;
}
Expand description

A trait that represents anything that file can be sent to

The trait is implemented for TcpStream right away but you might want to implement your own thing, for example to prepend the data with file length header

Required Methods§

Source

fn write_file<O: FileOpener>( &mut self, file: &mut Sendfile<O>, ) -> Result<usize, Error>

This method does the actual sendfile call

Note: this method is called in other thread

Source

fn poll_write(&self) -> Async<()>

Test whether this socket is ready to be written to or not.

If socket isn’t writable current taks must be scheduled to get a notification when socket does become writable.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Destination for TcpStream

Source§

fn write_file<O: FileOpener>( &mut self, file: &mut Sendfile<O>, ) -> Result<usize, Error>

Source§

fn poll_write(&self) -> Async<()>

Implementors§