pub fn push<V>(&mut self, value: &V) -> Result<()>
    where V: Serialize,
  {
    // serialize the data
    let serialized = serde_msgpack::to_vec(value).map_err(Error::MsgPackEnc)?;
    // get the length of the serialized data
    let len = serialized.len();
    // add the length to the header
    self.header.push(len as u64);
    // add length to master length
    self.len += len as u64;
    // get the size of the data file according to the updated header
    // let size: u64 = self.header.iter().sum();
    let mut data_file = self.data_file.borrow_mut();
    // set the data file's length
    data_file.set_len(self.len).map_err(Error::Io)?;
    // seek to the start of the new data
    data_file.seek(SeekFrom::End(-(len as i64))).map_err(Error::Io)?;
    // write the new data
    data_file.write_all(&serialized).map_err(Error::Io)?;

    Ok(())
  }
/// Add an item to the end of the table.
// FIXME: if writing fails, the header is invalid
Add an item to the end of the table.
FIXME: if writing fails, the header is invalid
Add an item to the end of the table . FIXME : if writing fails the header is invalid
pub fn push<V>(&mut self, value: &V) -> Result<()>
    where V: Serialize,
  {
    // serialize the data
    let serialized = serde_msgpack::to_vec(value).map_err(Error::MsgPackEnc)?;
    // get the length of the serialized data
    let len = serialized.len();
    // add the length to the header
    self.header.push(len as u64);
    // add length to master length
    self.len += len as u64;
    // get the size of the data file according to the updated header
    // let size: u64 = self.header.iter().sum();
    let mut data_file = self.data_file.borrow_mut();
    // set the data file's length
    data_file.set_len(self.len).map_err(Error::Io)?;
    // seek to the start of the new data
    data_file.seek(SeekFrom::End(-(len as i64))).map_err(Error::Io)?;
    // write the new data
    data_file.write_all(&serialized).map_err(Error::Io)?;
    Ok(())
  }
pub fn push < V > ( & mut self , value : & V ) -> Result < ( ) > where V : Serialize , { // serialize the data let serialized = serde_msgpack :: to_vec ( value ) . map_err ( Error :: MsgPackEnc ) ? ; // get the length of the serialized data let len = serialized . len ( ) ; // add the length to the header self . header . push ( len as u64 ) ; // add length to master length self . len += len as u64 ; // get the size of the data file according to the updated header // let size: u64 = self.header.iter().sum(); let mut data_file = self . data_file . borrow_mut ( ) ; // set the data file's length data_file . set_len ( self . len ) . map_err ( Error :: Io ) ? ; // seek to the start of the new data data_file . seek ( SeekFrom :: End ( - ( len as i64 ) ) ) . map_err ( Error :: Io ) ? ; // write the new data data_file . write_all ( & serialized ) . map_err ( Error :: Io ) ? ; Ok ( ( ) ) }
Add an item to the end of the table.
Add an item to the end of the table .
&mut self
value
&V