fn lmdb_find<P>(&self, db: Database, key: &[u8], predicate: P) -> Result<&[u8]>
    where
        P: Fn(&[u8]) -> bool,
    {
        // Ensure the entry exists
        // TODO: Fix upstream unwrap in lmdb crate's iter_from
        self.lmdb_get(db, key)?;

        let mut cursor = self.lmdb_txn().open_ro_cursor(db)?;
        let mut result = None;

        // TODO: Remove earlier check once this no longer panics on missing keys
        for (cursor_key, value) in cursor.iter_from(key) {
            if cursor_key != key {
                return Err(ErrorKind::NotFound("key not found".to_string()).into());
            }

            if predicate(value) {
                result = Some(value);
                break;
            }
        }

        result.ok_or_else(|| ErrorKind::NotFound("key not found".to_string()).into())
    }
/// Perform a search of the given database, looking for an entry that matches the predicate
// TODO: since LMDB is ordered, we could e.g. perform a binary search
Perform a search of the given database, looking for an entry that matches the predicate
TODO: since LMDB is ordered, we could e.g. perform a binary search
Perform a search of the given database looking for an entry that matches the predicate TODO : since LMDB is ordered we could e . g . perform a binary search
fn lmdb_find<P>(&self, db: Database, key: &[u8], predicate: P) -> Result<&[u8]>
    where
        P: Fn(&[u8]) -> bool,
    {
        // Ensure the entry exists
        // TODO: Fix upstream unwrap in lmdb crate's iter_from
        self.lmdb_get(db, key)?;
        let mut cursor = self.lmdb_txn().open_ro_cursor(db)?;
        let mut result = None;
        // TODO: Remove earlier check once this no longer panics on missing keys
        for (cursor_key, value) in cursor.iter_from(key) {
            if cursor_key != key {
                return Err(ErrorKind::NotFound("key not found".to_string()).into());
            }
            if predicate(value) {
                result = Some(value);
                break;
            }
        }
        result.ok_or_else(|| ErrorKind::NotFound("key not found".to_string()).into())
    }
fn lmdb_find < P > ( & self , db : Database , key : & [ u8 ] , predicate : P ) -> Result < & [ u8 ] > where P : Fn ( & [ u8 ] ) -> bool , { // Ensure the entry exists // TODO: Fix upstream unwrap in lmdb crate's iter_from self . lmdb_get ( db , key ) ? ; let mut cursor = self . lmdb_txn ( ) . open_ro_cursor ( db ) ? ; let mut result = None ; // TODO: Remove earlier check once this no longer panics on missing keys for ( cursor_key , value ) in cursor . iter_from ( key ) { if cursor_key != key { return Err ( ErrorKind :: NotFound ( " " . to_string ( ) ) . into ( ) ) ; } if predicate ( value ) { result = Some ( value ) ; break ; } } result . ok_or_else ( | | ErrorKind :: NotFound ( " " . to_string ( ) ) . into ( ) ) }
Perform a search of the given database, looking for an entry that matches the predicate
TODO: since LMDB is ordered, we could e.g.
Perform a search of the given database looking for an entry that matches the predicate TODO : since LMDB is ordered we could e . g .
&self
db
Database
key
&[u8]
predicate
P
&self
db
Database
key
&[u8]
predicate
P