Skip to main content

Table

Struct Table 

Source
pub struct Table {
    pub record_type: RecordType,
    pub unknown_free_list: u32,
    pub slots: Vec<Slot>,
    pub indexes: TableIndexes,
}

Fields§

§record_type: RecordType§unknown_free_list: u32

Purpose unknown, but it matters: macOS writes 0x1d for a table that has never held a record and 0 once one is stored. Leaving 0x1d in place after inserting a record makes the Security framework treat the first slot as free and overwrite it.

§slots: Vec<Slot>

Record slots in file order. A slot’s index is the record number it holds.

§indexes: TableIndexes

The table’s index region.

Implementations§

Source§

impl Table

Source

pub fn records(&self) -> impl Iterator<Item = &Record>

Live records, skipping free and empty slots.

Source

pub fn records_mut(&mut self) -> impl Iterator<Item = &mut Record>

Source

pub fn record_count(&self) -> usize

Source

pub fn next_record_number(&self) -> u32

Lowest unused record number. macOS numbers records from 0 upward.

Source

pub fn insert(&mut self, record: Record)

Append a record, reusing a never-used slot when one exists.

Free-list slots are left alone: their values chain macOS’s record-number allocator, and overwriting one would break the chain.

Source

pub fn unique_index_attribute_ids(&self) -> Option<&[u32]>

The attributes of the table’s unique index, by id.

None when this build could not parse the index region, or the table declares no unique index.

Source

pub fn has_record_with_unique_key( &self, relation: &Relation, attributes: &[Option<Value>], ) -> bool

True when a record already has the same key as attributes under the table’s unique index.

The unique index is the one the region marks kind == 1; the attributes it names are the relation’s notion of identity, which is what macOS refuses a duplicate of. A table whose index region this build could not parse answers false: it cannot tell, and refusing a write macOS would accept is worse than allowing it.

Source

pub fn rebuild_indexes(&mut self, relation: &Relation) -> Result<()>

Rebuild every index from the table’s records.

Rebuilding rather than patching keeps the indexes consistent with the records by construction; tests/keychain_index.rs checks that a rebuild reproduces the entries and the ordering macOS wrote.

Trait Implementations§

Source§

impl Clone for Table

Source§

fn clone(&self) -> Table

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 Table

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Table

§

impl RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl UnsafeUnpin for Table

§

impl UnwindSafe for Table

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V