pub fn pop<V>(&mut self) -> Result<Option<V>>
    where V: DeserializeOwned,
  {
    // make sure there's data to pop
    if self.header.is_empty() {
      return Ok(None);
    }

    // pop the length from the header
    // we just checked to make sure the header's not empty
    let len = self.header.pop().unwrap();

    // calculate start point (note that in order to truncate, we have to do this, so we can't just
    // relative seek from the end of the file)
    // let start: u64 = self.header[..self.header.len()].iter().sum();
    let start = self.len - len;

    let mut data_file = self.data_file.borrow_mut();

    // seek to the start
    data_file.seek(SeekFrom::Start(start)).map_err(Error::Io)?;

    // allocate a vec to store the data
    let mut data = vec![0; len as usize];
    // read the data
    data_file.read_exact(&mut data).map_err(Error::Io)?;

    // truncate the file
    data_file.set_len(start).map_err(Error::Io)?;

    // attempt to deserialize
    serde_msgpack::from_slice(&data).map_err(Error::MsgPackDec).map(Some)
  }
/// Remove an item from the end of the table, if there is an item to remove.
///
/// If a deserialization error occurs, the data that was popped will be lost.
///
/// This will return `Ok(None)` if the table is empty.
Remove an item from the end of the table, if there is an item to remove.
If a deserialization error occurs, the data that was popped will be lost.

This will return `Ok(None)` if the table is empty.
Remove an item from the end of the table if there is an item to remove . If a deserialization error occurs the data that was popped will be lost . This will return ` Ok ( None ) ` if the table is empty .
pub fn pop<V>(&mut self) -> Result<Option<V>>
    where V: DeserializeOwned,
  {
    // make sure there's data to pop
    if self.header.is_empty() {
      return Ok(None);
    }
    // pop the length from the header
    // we just checked to make sure the header's not empty
    let len = self.header.pop().unwrap();
    // calculate start point (note that in order to truncate, we have to do this, so we can't just
    // relative seek from the end of the file)
    // let start: u64 = self.header[..self.header.len()].iter().sum();
    let start = self.len - len;
    let mut data_file = self.data_file.borrow_mut();
    // seek to the start
    data_file.seek(SeekFrom::Start(start)).map_err(Error::Io)?;
    // allocate a vec to store the data
    let mut data = vec![0; len as usize];
    // read the data
    data_file.read_exact(&mut data).map_err(Error::Io)?;
    // truncate the file
    data_file.set_len(start).map_err(Error::Io)?;
    // attempt to deserialize
    serde_msgpack::from_slice(&data).map_err(Error::MsgPackDec).map(Some)
  }
pub fn pop < V > ( & mut self ) -> Result < Option < V > > where V : DeserializeOwned , { // make sure there's data to pop if self . header . is_empty ( ) { return Ok ( None ) ; } // pop the length from the header // we just checked to make sure the header's not empty let len = self . header . pop ( ) . unwrap ( ) ; // calculate start point (note that in order to truncate, we have to do this, so we can't just // relative seek from the end of the file) // let start: u64 = self.header[..self.header.len()].iter().sum(); let start = self . len - len ; let mut data_file = self . data_file . borrow_mut ( ) ; // seek to the start data_file . seek ( SeekFrom :: Start ( start ) ) . map_err ( Error :: Io ) ? ; // allocate a vec to store the data let mut data = vec ! [ 0 len as usize ] ; // read the data data_file . read_exact ( & mut data ) . map_err ( Error :: Io ) ? ; // truncate the file data_file . set_len ( start ) . map_err ( Error :: Io ) ? ; // attempt to deserialize serde_msgpack :: from_slice ( & data ) . map_err ( Error :: MsgPackDec ) . map ( Some ) }
Remove an item from the end of the table, if there is an item to remove.
Remove an item from the end of the table if there is an item to remove .
&mut self