pub struct OrdinalSpace<'a> { /* private fields */ }Expand description
oid ⇄ ordinal, as a Copy view that owns nothing.
Two layouts share it. A sorted buffer alone (Self::new) is the sealed
archive’s space. An OrdinalTable’s view adds the fanout and the appended
part: ordinal o < base_len is the slice at o * oid_len of base, and
o >= base_len is the slice at (o - base_len) * oid_len of extra, which
is in arrival order and is searched through extra_sorted (its ordinals,
sorted by oid).
Implementations§
Source§impl<'a> OrdinalSpace<'a>
impl<'a> OrdinalSpace<'a>
Sourcepub fn new(raw: &'a [u8], oid_len: usize) -> Self
pub fn new(raw: &'a [u8], oid_len: usize) -> Self
Borrow a flat, sorted, fixed-width oid buffer as the ordinal space. The sort is the caller’s invariant (every sealed builder produces it in oid-lexicographic order); the binary search below rests on it.
pub fn is_empty(&self) -> bool
pub fn oid_len(&self) -> usize
Sourcepub fn oid(&self, ordinal: u32) -> Option<&'a [u8]>
pub fn oid(&self, ordinal: u32) -> Option<&'a [u8]>
ordinal → raw oid, a slice into the flat buffers. None for an ordinal
outside the space.
Sourcepub fn ordinal_of_raw(&self, oid: &[u8]) -> Option<u32>
pub fn ordinal_of_raw(&self, oid: &[u8]) -> Option<u32>
raw oid → ordinal: the fanout narrows the base to one 16-bit prefix, a
binary search finishes it, and the appended part is searched through
its sorted index. This is the exact inverse of Self::oid.
Sourcepub fn ordinal_of_hex(&self, hex: &str) -> Option<u32>
pub fn ordinal_of_hex(&self, hex: &str) -> Option<u32>
hex oid → ordinal. Decodes the hex into a stack buffer (≤ 32 bytes), so a lookup allocates nothing, then searches the raw form. Not on any serving path: the walk and the builder carry raw oids.