fn range<'a>(
        &'a self,
        start: Option<&[u8]>,
        end: Option<&[u8]>,
        order: Order,
    ) -> FfiResult<(Box<dyn Iterator<Item = StorageIteratorItem> + 'a>, u64)> {
        let bounds = range_bounds(start, end);

        // BTreeMap.range panics if range is start > end.
        // However, this cases represent just empty range and we treat it as such.
        match (bounds.start_bound(), bounds.end_bound()) {
            (Bound::Included(start), Bound::Excluded(end)) if start > end => {
                return Ok((Box::new(iter::empty()), 0));
            }
            _ => {}
        }

        let iter = self.data.range(bounds);
        Ok(match order {
            Order::Ascending => (
                Box::new(
                    iter.map(clone_item)
                        .map(|item| {
                            let gas_cost = (item.0.len() + item.1.len()) as u64;
                            (item, gas_cost)
                        })
                        .map(FfiResult::Ok),
                ),
                0,
            ),
            Order::Descending => (
                Box::new(
                    iter.rev()
                        .map(clone_item)
                        .map(|item| {
                            let gas_cost = (item.0.len() + item.1.len()) as u64;
                            (item, gas_cost)
                        })
                        .map(FfiResult::Ok),
                ),
                0,
            ),
        })
    }
/// range allows iteration over a set of keys, either forwards or backwards
/// uses standard rust range notation, and eg db.range(b"foo"..b"bar") also works reverse
range allows iteration over a set of keys, either forwards or backwards
uses standard rust range notation, and eg db.range(b"foo"..b"bar") also works reverse
range allows iteration over a set of keys either forwards or backwards uses standard rust range notation and eg db . range ( b " foo " .. b " bar " ) also works reverse
fn range<'a>(
        &'a self,
        start: Option<&[u8]>,
        end: Option<&[u8]>,
        order: Order,
    ) -> FfiResult<(Box<dyn Iterator<Item = StorageIteratorItem> + 'a>, u64)> {
        let bounds = range_bounds(start, end);
        // BTreeMap.range panics if range is start > end.
        // However, this cases represent just empty range and we treat it as such.
        match (bounds.start_bound(), bounds.end_bound()) {
            (Bound::Included(start), Bound::Excluded(end)) if start > end => {
                return Ok((Box::new(iter::empty()), 0));
            }
            _ => {}
        }
        let iter = self.data.range(bounds);
        Ok(match order {
            Order::Ascending => (
                Box::new(
                    iter.map(clone_item)
                        .map(|item| {
                            let gas_cost = (item.0.len() + item.1.len()) as u64;
                            (item, gas_cost)
                        })
                        .map(FfiResult::Ok),
                ),
                0,
            ),
            Order::Descending => (
                Box::new(
                    iter.rev()
                        .map(clone_item)
                        .map(|item| {
                            let gas_cost = (item.0.len() + item.1.len()) as u64;
                            (item, gas_cost)
                        })
                        .map(FfiResult::Ok),
                ),
                0,
            ),
        })
    }
fn range < ' a > ( & ' a self , start : Option < & [ u8 ] > , end : Option < & [ u8 ] > , order : Order , ) -> FfiResult < ( Box < dyn Iterator < Item = StorageIteratorItem > + ' a > , u64 ) > { let bounds = range_bounds ( start , end ) ; // BTreeMap.range panics if range is start > end. // However, this cases represent just empty range and we treat it as such. match ( bounds . start_bound ( ) , bounds . end_bound ( ) ) { ( Bound :: Included ( start ) , Bound :: Excluded ( end ) ) if start > end => { return Ok ( ( Box :: new ( iter :: empty ( ) ) , 0 ) ) ; } _ => { } } let iter = self . data . range ( bounds ) ; Ok ( match order { Order :: Ascending => ( Box :: new ( iter . map ( clone_item ) . map ( | item | { let gas_cost = ( item . 0 . len ( ) + item . 1 . len ( ) ) as u64 ; ( item , gas_cost ) } ) . map ( FfiResult :: Ok ) , ) , 0 , ) , Order :: Descending => ( Box :: new ( iter . rev ( ) . map ( clone_item ) . map ( | item | { let gas_cost = ( item . 0 . len ( ) + item . 1 . len ( ) ) as u64 ; ( item , gas_cost ) } ) . map ( FfiResult :: Ok ) , ) , 0 , ) , } ) }
range allows iteration over a set of keys, either forwards or backwards
uses standard rust range notation, and eg db.range(b"foo"..b"bar") also works reverse
range allows iteration over a set of keys either forwards or backwards uses standard rust range notation and eg db . range ( b " foo " .. b " bar " ) also works reverse
&'a self
start
Option<&[u8]>
end
Option<&[u8]>
order
Order
&'a self
start
Option<&[u8]>
end
Option<&[u8]>
order
Order