Skip to main content

OidList

Struct OidList 

Source
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

Source

pub fn new() -> Self

An empty list. Its width is decided by the first push.

Source

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.

Source

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.

Source

pub fn iter(&self) -> impl ExactSizeIterator<Item = &[u8]> + '_

Every oid, in push order, borrowed out of the one buffer.

Source

pub fn len(&self) -> usize

How many oids — not how many bytes.

Source

pub fn is_empty(&self) -> bool

Whether it names nothing. For a voucher this is the clone case.

Source

pub fn oid_len(&self) -> usize

The width of one oid, or 0 for an empty list.

Source

pub fn contains(&self, oid: &[u8]) -> bool

A linear scan. Fine for a guard and for a handful of probes; wrong in a loop over a request. See the type’s header.

Trait Implementations§

Source§

impl Clone for OidList

Source§

fn clone(&self) -> OidList

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OidList

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OidList

Source§

fn default() -> OidList

Returns the “default value” for a type. Read more
Source§

impl Eq for OidList

Source§

impl<T: AsRef<[u8]>> FromIterator<T> for OidList

Source§

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.

Source§

impl PartialEq for OidList

Source§

fn eq(&self, other: &OidList) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for OidList

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.