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: u32Modification time as a Unix timestamp (seconds since epoch).
blob_size: u32Byte length of the (possibly encrypted) payload stored across all chunks.
blob_key_slot: u8PIV slot used for encryption (0 = unencrypted).
blob_plain_size: u32Byte length of the plaintext before encryption.
is_compressed: boolWhether the stored payload is compressed (C-bit = bit 23 of blob_plain_size).
blob_name: StringImplementations§
Source§impl Object
impl Object
Sourcepub fn from_bytes(index: u8, data: &[u8]) -> Result<Self>
pub fn from_bytes(index: u8, data: &[u8]) -> Result<Self>
Deserialize a PIV object from raw bytes.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
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_lenbytes. - Continuation chunk:
0x0B + payload_lenbytes.
The result is always in the range OBJECT_MIN_SIZE..=OBJECT_MAX_SIZE.
Sourcepub fn reset(&mut self)
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.
Sourcepub fn head_payload_capacity(_object_size: usize, name_len: usize) -> usize
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.
Sourcepub fn continuation_payload_capacity(_object_size: usize) -> usize
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.
pub fn is_empty(&self) -> bool
pub fn is_head(&self) -> bool
pub fn is_encrypted(&self) -> bool
Sourcepub fn set_payload(&mut self, payload: Vec<u8>)
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.
pub fn index(&self) -> u8
pub fn age(&self) -> u32
pub fn chunk_pos(&self) -> u8
pub fn next_chunk(&self) -> u8
Sourcepub fn payload_len(&self) -> usize
pub fn payload_len(&self) -> usize
Length of the raw chunk payload bytes.