pub fn read_bytes(&mut self) -> Result<Vec<u8>> {
        if self.offset >= self.inner.len() {
            return Err(Error::UnexpectedEof);
        }

        let slice = &self.inner[self.offset..];
        if slice.len() < 4 {
            return Err(Error::InvalidFormat);
        }

        let size = u32::from_be_bytes(slice[..4].try_into().unwrap()) as usize;
        if slice.len() < size + 4 {
            return Err(Error::InvalidFormat);
        }

        self.offset += size + 4;
        let result = slice[4..size + 4].to_vec();

        Ok(result)
    }
/// Reads a byte buffer from the wrapped byte sequence and
/// returns it as a `Vec<u8>`.
/// The buffer is represented by it's length as `u32` value
/// followed by the actual bytes to read.
///
/// # Example
/// ```rust
/// # use sshcerts::ssh::Reader;
/// let data = vec![0, 0, 0, 13, 97, 32, 116, 101, 115, 116, 32, 115, 116, 114, 105, 110, 103];
/// let mut reader = Reader::new(&data);
/// let bytes = reader.read_bytes().unwrap();
/// assert_eq!(bytes, [97, 32, 116, 101, 115, 116, 32, 115, 116, 114, 105, 110, 103]);
/// ```
Reads a byte buffer from the wrapped byte sequence and
returns it as a `Vec`.
The buffer is represented by it's length as `u32` value
followed by the actual bytes to read.
Reads a byte buffer from the wrapped byte sequence and returns it as a ` Vec ` . The buffer is represented by it ' s length as ` u32 ` value followed by the actual bytes to read .
pub fn read_bytes(&mut self) -> Result<Vec<u8>> {
        if self.offset >= self.inner.len() {
            return Err(Error::UnexpectedEof);
        }
        let slice = &self.inner[self.offset..];
        if slice.len() < 4 {
            return Err(Error::InvalidFormat);
        }
        let size = u32::from_be_bytes(slice[..4].try_into().unwrap()) as usize;
        if slice.len() < size + 4 {
            return Err(Error::InvalidFormat);
        }
        self.offset += size + 4;
        let result = slice[4..size + 4].to_vec();
        Ok(result)
    }
pub fn read_bytes ( & mut self ) -> Result < Vec < u8 > > { if self . offset >= self . inner . len ( ) { return Err ( Error :: UnexpectedEof ) ; } let slice = & self . inner [ self . offset .. ] ; if slice . len ( ) < 4 { return Err ( Error :: InvalidFormat ) ; } let size = u32 :: from_be_bytes ( slice [ .. 4 ] . try_into ( ) . unwrap ( ) ) as usize ; if slice . len ( ) < size + 4 { return Err ( Error :: InvalidFormat ) ; } self . offset += size + 4 ; let result = slice [ 4 .. size + 4 ] . to_vec ( ) ; Ok ( result ) }
Reads a byte buffer from the wrapped byte sequence and
returns it as a `Vec<u8>`.
Reads a byte buffer from the wrapped byte sequence and returns it as a ` Vec<u8 > ` .
&mut self
example
None
use sshcerts::ssh::reader;
None