Skip to main content

Store

Struct Store 

Source
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: u32

Highest age seen across all objects; new objects get age = store_age + 1.

Implementations§

Source§

impl Store

Source

pub fn from_device(reader: &str, piv: &dyn PivBackend) -> Result<Self>

Read all objects from the device and construct a Store.

Source

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.

Source

pub fn sanitize(&mut self)

Remove corrupt / orphaned / duplicate objects.

Source

pub fn sync( &mut self, piv: &dyn PivBackend, management_key: Option<&str>, pin: Option<&str>, ) -> Result<()>

Write all dirty objects back to the device.

Source

pub fn alloc_free(&self) -> Option<u8>

Allocate the next free object index, or None if the store is full.

Source

pub fn free_count(&self) -> usize

Number of free (empty) slots.

Source

pub fn find_head(&self, name: &str) -> Option<&Object>

Find the head object for a blob by name.

Source

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.

Source

pub fn now_unix() -> u32

Current Unix timestamp (seconds), for use as blob_mtime.

Source

pub fn next_age(&mut self) -> u32

Bump the store age and return the new value for a new chunk.

Source

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.

Auto Trait Implementations§

§

impl Freeze for Store

§

impl RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

§

impl UnwindSafe for Store

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> 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> Same for T

Source§

type Output = T

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