pub struct OidList { /* private fields */ }Expand description
Many raw oids in ONE allocation.
A Vec<Vec<u8>> of oids is one heap allocation per object, and the two
things a store does with a repository-sized oid set — hand it across this
contract, and ask it “do you hold this” — need neither. This is the flat
form: len × oid_len bytes in a single buffer, iterated as slices.
§Why it is here and not in either engine
Because both engines cross this seam with one. MEASURED on oden 2026-08-15,
the znippy engine serving a 69-object negotiated fetch out of the nornir
mirror (12 303 objects, have closure 12 112): ReachSet::client_has
alone was 12 112 Strings and 12 112 Vec<u8>s per request on the way
through a hex round-trip, for a voucher whose only consumers ask its length
and its membership. The gix engine pays the smaller half of the same bill —
one Vec<u8> per ObjectId — and it pays it for the same reason: the
contract’s type demanded one. Fixing it in one engine and not the other
would be the twinning LAW 5 forbids.
§What it is not
Not a set: contains is a linear scan, stated rather
than hidden, because this type’s job is carrying oids cheaply. A consumer
that asks membership per object builds its own index off
iter — a HashSet of fixed-size keys costs one
allocation for the table and none per entry, which is the whole point.
Not sorted, and not deduplicated: it preserves exactly what was pushed.
Implementations§
Source§impl OidList
impl OidList
Sourcepub fn with_capacity(oids: usize, oid_len: usize) -> Self
pub fn with_capacity(oids: usize, oid_len: usize) -> Self
An empty list with room for oids oids of oid_len bytes, in one
allocation. The width is still decided by the first push — this only
reserves.
Sourcepub fn push(&mut self, oid: &[u8]) -> Result<()>
pub fn push(&mut self, oid: &[u8]) -> Result<()>
Append one raw oid.
The first push fixes the width; a later one of a different width is an
error rather than a silently reinterpreted buffer, because every
accessor here is len-strided and a mixed list would hand back oids
that never existed.
Sourcepub fn iter(&self) -> impl ExactSizeIterator<Item = &[u8]> + '_
pub fn iter(&self) -> impl ExactSizeIterator<Item = &[u8]> + '_
Every oid, in push order, borrowed out of the one buffer.
Trait Implementations§
impl Eq for OidList
Source§impl<T: AsRef<[u8]>> FromIterator<T> for OidList
impl<T: AsRef<[u8]>> FromIterator<T> for OidList
Source§fn from_iter<I: IntoIterator<Item = T>>(items: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(items: I) -> Self
Collect from anything oid-shaped — Vec<u8>, &[u8], a gix
ObjectId’s bytes.
A width disagreement panics here, because a FromIterator cannot
fail and an engine that mixes hash kinds inside one repository has a
bigger problem than this list. Use push where the
input is not the store’s own index.