little-kitty 0.0.3

A low-level interface for the Kitty Graphics Protocol
Documentation
use std::io::*;

//
// ReadChunk
//

/// Read no more than a specified number of bytes.
pub trait ReadChunk
where
    Self: Sized,
{
    /// Read no more than a specified number of bytes.
    fn read_chunk(self, at_most: u64, buffer: &mut Vec<u8>) -> Result<Self>;
}

impl<ReadT> ReadChunk for ReadT
where
    ReadT: Read,
{
    fn read_chunk(self, at_most: u64, buffer: &mut Vec<u8>) -> Result<Self> {
        let mut reader = self.take(at_most);
        reader.read_to_end(buffer)?;
        Ok(reader.into_inner())
    }
}