Introduce a method to get the meta of an update on the UpdateStore

This commit is contained in:
Clément Renault 2020-10-18 17:19:04 +02:00
parent eca49e3a03
commit edb8c99fbe
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -170,4 +170,21 @@ impl<M: 'static + Send + Sync> UpdateStore<M> {
Ok(()) Ok(())
} }
/// Returns the update associated meta or `None` if the update deosn't exist.
pub fn update_meta(&self, update_id: u64) -> heed::Result<Option<M>>
where M: for<'a> Deserialize<'a>,
{
let rtxn = self.env.read_txn()?;
let key = BEU64::new(update_id);
if let Some(meta) = self.pending_meta.get(&rtxn, &key)? {
return Ok(Some(meta));
}
match self.processed_meta.get(&rtxn, &key)? {
Some(meta) => Ok(Some(meta)),
None => Ok(None),
}
}
} }