Skip to content

Instantly share code, notes, and snippets.

@rrichardson
Created October 23, 2017 17:59
Show Gist options
  • Save rrichardson/98943359327f5f7bdda6b07b25f08e13 to your computer and use it in GitHub Desktop.
Save rrichardson/98943359327f5f7bdda6b07b25f08e13 to your computer and use it in GitHub Desktop.
pub fn get<'de, V>(&self, key: &[u8]) -> Result<Option<V>, Error>
where
V: Deserialize<'de>,
{
let res = self.db.get_cf(self.cf, key)?;
if let Some(inbuf) = res {
let v: V = deserialize(&inbuf[HDR_LEN..]).map_err(Error::from)?;
Ok(Some(v))
} else {
Ok(None)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment