Skip to main content

Object

Struct Object 

Source
pub struct Object {
    pub blob_mtime: u32,
    pub blob_size: u32,
    pub blob_key_slot: u8,
    pub blob_plain_size: u32,
    pub is_compressed: bool,
    pub blob_name: String,
    /* private fields */
}
Expand description

One PIV data object. May be empty (age == 0) or occupied (age > 0).

Fields§

§blob_mtime: u32

Modification time as a Unix timestamp (seconds since epoch).

§blob_size: u32

Byte length of the (possibly encrypted) payload stored across all chunks.

§blob_key_slot: u8

PIV slot used for encryption (0 = unencrypted).

§blob_plain_size: u32

Byte length of the plaintext before encryption.

§is_compressed: bool

Whether the stored payload is compressed (C-bit = bit 23 of blob_plain_size).

§blob_name: String

Implementations§

Source§

impl Object

Source

pub fn from_bytes(index: u8, data: &[u8]) -> Result<Self>

Deserialize a PIV object from raw bytes.

Source

pub fn to_bytes(&self) -> Vec<u8>

Serialize this object to the minimum number of bytes required.

  • Empty slot (age == 0): 9-byte sentinel (common header only).
  • Head chunk: 0x17 + name_len + payload_len bytes.
  • Continuation chunk: 0x0B + payload_len bytes.

The result is always in the range OBJECT_MIN_SIZE..=OBJECT_MAX_SIZE.

Source

pub fn reset(&mut self)

Mark this object as empty (age = 0) and dirty.

Uses an explicit full struct literal so that adding a new field causes a compile error here, forcing the author to decide whether it should be preserved or zeroed on reset.

Source

pub fn head_payload_capacity(_object_size: usize, name_len: usize) -> usize

Maximum payload capacity in a head chunk given a name of name_len bytes.

Uses OBJECT_MAX_SIZE (the hard limit) regardless of the object_size argument, which is ignored and retained only for call-site compatibility.

Source

pub fn continuation_payload_capacity(_object_size: usize) -> usize

Maximum payload capacity in a continuation chunk.

Uses OBJECT_MAX_SIZE (the hard limit). The object_size argument is ignored and retained only for call-site compatibility.

Source

pub fn is_empty(&self) -> bool

Source

pub fn is_head(&self) -> bool

Source

pub fn is_encrypted(&self) -> bool

Source

pub fn set_payload(&mut self, payload: Vec<u8>)

Set the raw chunk payload. Intended for test helpers that need to construct synthetic objects via Store::make_object.

Source

pub fn index(&self) -> u8

Source

pub fn age(&self) -> u32

Source

pub fn chunk_pos(&self) -> u8

Source

pub fn next_chunk(&self) -> u8

Source

pub fn payload(&self) -> &[u8]

Raw chunk payload bytes (read-only).

Source

pub fn payload_len(&self) -> usize

Length of the raw chunk payload bytes.

Source

pub fn object_size(&self) -> usize

Trait Implementations§

Source§

impl Clone for Object

Source§

fn clone(&self) -> Object

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Object

Source§

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

Formats the value using the given formatter. Read more

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> 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