pub struct Store {
pub reader: String,
pub object_size: usize,
pub object_count: u8,
pub store_key_slot: u8,
pub objects: Vec<Object>,
pub store_age: u32,
}Expand description
The full set of PIV objects that make up one yb store.
Fields§
§reader: String§object_size: usize§object_count: u8§store_key_slot: u8§objects: Vec<Object>§store_age: u32Highest age seen across all objects; new objects get age = store_age + 1.
Implementations§
Source§impl Store
impl Store
Sourcepub fn from_device(reader: &str, piv: &dyn PivBackend) -> Result<Self>
pub fn from_device(reader: &str, piv: &dyn PivBackend) -> Result<Self>
Read all objects from the device and construct a Store.
Sourcepub fn format(
reader: &str,
piv: &dyn PivBackend,
object_count: u8,
store_key_slot: u8,
management_key: Option<&str>,
pin: Option<&str>,
) -> Result<Self>
pub fn format( reader: &str, piv: &dyn PivBackend, object_count: u8, store_key_slot: u8, management_key: Option<&str>, pin: Option<&str>, ) -> Result<Self>
Write a fresh empty store to the device (yb format).
Each slot is initialised with a compact 9-byte empty-slot sentinel
(spec 0010). No object_size parameter — size is determined
dynamically at write time.
Sourcepub fn sync(
&mut self,
piv: &dyn PivBackend,
management_key: Option<&str>,
pin: Option<&str>,
) -> Result<()>
pub fn sync( &mut self, piv: &dyn PivBackend, management_key: Option<&str>, pin: Option<&str>, ) -> Result<()>
Write all dirty objects back to the device.
Sourcepub fn alloc_free(&self) -> Option<u8>
pub fn alloc_free(&self) -> Option<u8>
Allocate the next free object index, or None if the store is full.
Sourcepub fn free_count(&self) -> usize
pub fn free_count(&self) -> usize
Number of free (empty) slots.
Sourcepub fn find_head(&self, name: &str) -> Option<&Object>
pub fn find_head(&self, name: &str) -> Option<&Object>
Find the head object for a blob by name.
Sourcepub fn chunk_chain(&self, head_index: u8) -> Vec<u8> ⓘ
pub fn chunk_chain(&self, head_index: u8) -> Vec<u8> ⓘ
Follow the chunk chain from a head, collecting all chunk indices in order.
Includes a cycle guard: if a next_chunk pointer revisits an already-
seen index (corrupt store), the walk stops early so the function always
terminates.
Sourcepub fn make_object(&self, p: ObjectParams) -> Object
pub fn make_object(&self, p: ObjectParams) -> Object
Construct a new occupied Object for this store, filling all common
header fields from the store’s own metadata. Blob-specific fields
(blob_mtime, blob_size, blob_key_slot, blob_plain_size,
is_compressed, blob_name, payload) are left at their zero values
for the caller to set.