pub struct EncodedKeyRange {
pub start: Bound<EncodedKey>,
pub end: Bound<EncodedKey>,
}Fields§
§start: Bound<EncodedKey>§end: Bound<EncodedKey>Implementations§
Source§impl EncodedKeyRange
impl EncodedKeyRange
pub fn new(start: Bound<EncodedKey>, end: Bound<EncodedKey>) -> Self
Sourcepub fn prefix(prefix: &[u8]) -> Self
pub fn prefix(prefix: &[u8]) -> Self
Generates a key range for a key prefix, used e.g. for prefix scans.
The exclusive end bound is generated by adding 1 to the value of the last byte. If the last byte(s) is 0xff (so adding 1 would saturation), we instead find the latest non-0xff byte, increment that, and truncate the rest. If all bytes are 0xff, we scan to the end of the range, since there can’t be other prefixes after it.
pub fn with_prefix(&self, prefix: EncodedKey) -> Self
Sourcepub fn start_end(start: Option<EncodedKey>, end: Option<EncodedKey>) -> Self
pub fn start_end(start: Option<EncodedKey>, end: Option<EncodedKey>) -> Self
Constructs a key range from an optional inclusive start key to an optional inclusive end key.
start: If provided, marks the inclusive lower bound of the range. IfNone, the range is unbounded below.end: If provided, marks the inclusive upper bound of the range. IfNone, the range is unbounded above.
This function does not modify the input keys and assumes they are
already exact keys (not prefixes). If you need to scan all keys
with a given prefix, use EncodedKeyRange::prefix instead.
Useful for scanning between two explicit keys in a sorted key-value store.
Sourcepub fn all() -> Self
pub fn all() -> Self
Constructs a key range that fragments the entire keyspace.
This range has no lower or upper bounds, making it suitable for full scans over all keys in a sorted key-value store.
Equivalent to: .. (in Rust range syntax)
Sourcepub fn parse(str: &str) -> Self
pub fn parse(str: &str) -> Self
Parses a human-readable range string into a KeyRange.
The expected format is <start>..[=]<end>, where:
<start>is the inclusive lower bound (optional),..separates the bounds,=after..makes the upper bound inclusive,<end>is the upper bound (optional).
Examples:
"a..z"=> start = Included(“a”), end = Excluded(“z”)"a..=z"=> start = Included(“a”), end = Included(“z”)"..z"=> start = Unbounded, end = Excluded(“z”)"a.."=> start = Included(“a”), end = Unbounded
If parsing fails, it defaults to a degenerate range from 0xff to
0xff (empty).
Trait Implementations§
Source§impl Clone for EncodedKeyRange
impl Clone for EncodedKeyRange
Source§fn clone(&self) -> EncodedKeyRange
fn clone(&self) -> EncodedKeyRange
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EncodedKeyRange
impl Debug for EncodedKeyRange
Source§impl From<EncodedIndexKeyRange> for EncodedKeyRange
impl From<EncodedIndexKeyRange> for EncodedKeyRange
Source§fn from(range: EncodedIndexKeyRange) -> Self
fn from(range: EncodedIndexKeyRange) -> Self
Source§impl RangeBounds<EncodedKey> for EncodedKeyRange
impl RangeBounds<EncodedKey> for EncodedKeyRange
Source§fn start_bound(&self) -> Bound<&EncodedKey>
fn start_bound(&self) -> Bound<&EncodedKey>
§fn is_empty(&self) -> boolwhere
T: PartialOrd,
fn is_empty(&self) -> boolwhere
T: PartialOrd,
range_bounds_is_empty)true if the range contains no items.
One-sided ranges (RangeFrom, etc) always return false. Read moreAuto Trait Implementations§
impl Freeze for EncodedKeyRange
impl RefUnwindSafe for EncodedKeyRange
impl Send for EncodedKeyRange
impl Sync for EncodedKeyRange
impl Unpin for EncodedKeyRange
impl UnwindSafe for EncodedKeyRange
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)