pub fn write(&mut self, buf: &[u8]) -> Result<usize, String> {
    let vec = &mut self.inner;
    let pos: usize = self.pos.try_into().map_err(|_| {
      "cursor position exceeds maximum possible vector length".to_owned()
    })?;
    let len = vec.len();
    if len < pos {
      vec.resize(pos, 0);
    }
    {
      let space = vec.len() - pos;
      let (left, right) = buf.split_at(cmp::min(space, buf.len()));
      vec[pos..pos + left.len()].copy_from_slice(left);
      vec.extend_from_slice(right);
    }
    self.pos = (pos + buf.len()) as u64;
    Ok(buf.len())
  }
/// Writes `buf.len()` bytes into `buf`. Returns the number of bytes actually
/// read if successful, and throws an error if there aren't enough bytes to
/// read. # Errors
///
/// Will return `Err` if the cursor position exceeds maximum possible vector
/// length
Writes `buf.len()` bytes into `buf`. Returns the number of bytes actually
read if successful, and throws an error if there aren't enough bytes to
read. # Errors

Will return `Err` if the cursor position exceeds maximum possible vector
length
Writes ` buf . len () ` bytes into ` buf ` . Returns the number of bytes actually read if successful and throws an error if there aren ' t enough bytes to read . # Errors Will return ` Err ` if the cursor position exceeds maximum possible vector length
pub fn write(&mut self, buf: &[u8]) -> Result<usize, String> {
    let vec = &mut self.inner;
    let pos: usize = self.pos.try_into().map_err(|_| {
      "cursor position exceeds maximum possible vector length".to_owned()
    })?;
    let len = vec.len();
    if len < pos {
      vec.resize(pos, 0);
    }
    {
      let space = vec.len() - pos;
      let (left, right) = buf.split_at(cmp::min(space, buf.len()));
      vec[pos..pos + left.len()].copy_from_slice(left);
      vec.extend_from_slice(right);
    }
    self.pos = (pos + buf.len()) as u64;
    Ok(buf.len())
  }
pub fn write ( & mut self , buf : & [ u8 ] ) -> Result < usize , String > { let vec = & mut self . inner ; let pos : usize = self . pos . try_into ( ) . map_err ( | _ | { " " . to_owned ( ) } ) ? ; let len = vec . len ( ) ; if len < pos { vec . resize ( pos , 0 ) ; } { let space = vec . len ( ) - pos ; let ( left , right ) = buf . split_at ( cmp :: min ( space , buf . len ( ) ) ) ; vec [ pos .. pos + left . len ( ) ] . copy_from_slice ( left ) ; vec . extend_from_slice ( right ) ; } self . pos = ( pos + buf . len ( ) ) as u64 ; Ok ( buf . len ( ) ) }
Writes `buf.len()` bytes into `buf`.
Writes ` buf . len () ` bytes into ` buf ` .
&mut self
buf
&[u8]
&mut self
buf
&[u8]