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: u32Purpose 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: TableIndexesThe table’s index region.
Implementations§
Source§impl Table
impl Table
Sourcepub fn records(&self) -> impl Iterator<Item = &Record>
pub fn records(&self) -> impl Iterator<Item = &Record>
Live records, skipping free and empty slots.
pub fn records_mut(&mut self) -> impl Iterator<Item = &mut Record>
pub fn record_count(&self) -> usize
Sourcepub fn next_record_number(&self) -> u32
pub fn next_record_number(&self) -> u32
Lowest unused record number. macOS numbers records from 0 upward.
Sourcepub fn insert(&mut self, record: Record)
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.
Sourcepub fn unique_index_attribute_ids(&self) -> Option<&[u32]>
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.
Sourcepub fn has_record_with_unique_key(
&self,
relation: &Relation,
attributes: &[Option<Value>],
) -> bool
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.
Sourcepub fn rebuild_indexes(&mut self, relation: &Relation) -> Result<()>
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.