trait CopyRead: Read {
    // Required method
    fn properties(&self) -> CopyParams;

    // Provided methods
    fn drain_to<W: Write>(
        &mut self,
        _writer: &mut W,
        _limit: u64
    ) -> Result<u64> { ... }
    fn taken(&mut self, _bytes: u64) { ... }
    fn min_limit(&self) -> u64 { ... }
}

Required Methods§

source

fn properties(&self) -> CopyParams

Extracts the file descriptor and hints/metadata, delegating through wrappers if necessary.

Provided Methods§

source

fn drain_to<W: Write>(&mut self, _writer: &mut W, _limit: u64) -> Result<u64>

Implementations that contain buffers (i.e. BufReader) must transfer data from their internal buffers into writer until either the buffers are emptied or limit bytes have been transferred, whichever occurs sooner. If nested buffers are present the outer buffers must be drained first.

This is necessary to directly bypass the wrapper types while preserving the data order when operating directly on the underlying file descriptors.

source

fn taken(&mut self, _bytes: u64)

Updates Take wrappers to remove the number of bytes copied.

source

fn min_limit(&self) -> u64

The minimum of the limit of all Take<_> wrappers, u64::MAX otherwise. This method does not account for data BufReader buffers and would underreport the limit of a Take<BufReader<Take<_>>> type. Thus its result is only valid after draining the buffers via drain_to.

Implementors§