pub struct WriteObjectLayout { /* private fields */ }Expand description
Sealed layout cursor, retaining header metadata rather than object bytes.
Writers start at the header. Readers start after opening the header with
WriteObjectPrefix::opened_header. Hash each encoded piece, including the
prefix and length fields, before the final signature.
Implementations§
Source§impl WriteObjectLayout
impl WriteObjectLayout
Sourcepub fn new(
prefix: WriteObjectPrefix,
header: &[u8],
part_lengths: Vec<u64>,
) -> Result<Self, Error>
pub fn new( prefix: WriteObjectPrefix, header: &[u8], part_lengths: Vec<u64>, ) -> Result<Self, Error>
Begin producing a write from its header bytes and declared part lengths. Exactly one key is required for every part; lengths come from the header’s plaintext codec, which remains responsible for validating its fields.
Sourcepub fn prefix(&self) -> Result<Vec<u8>, Error>
pub fn prefix(&self) -> Result<Vec<u8>, Error>
Encode the cleartext prefix before supplying sealed chunks.
Sourcepub fn next_chunk(&self) -> Option<ObjectChunk>
pub fn next_chunk(&self) -> Option<ObjectChunk>
Coordinates for the next sealed chunk, or None when only the signature remains.
Sourcepub fn chunk_length(&self, prefix: &[u8]) -> Result<usize, Error>
pub fn chunk_length(&self, prefix: &[u8]) -> Result<usize, Error>
Validate a chunk length prefix against the next exact boundary before allocating.
Sourcepub fn encode_chunk(&mut self, bytes: &[u8]) -> Result<Vec<u8>, Error>
pub fn encode_chunk(&mut self, bytes: &[u8]) -> Result<Vec<u8>, Error>
Write the next length-prefixed sealed chunk, advancing only on success.
Sourcepub fn decode_chunk<'a>(
&mut self,
piece: &'a [u8],
) -> Result<(ObjectChunk, &'a [u8]), Error>
pub fn decode_chunk<'a>( &mut self, piece: &'a [u8], ) -> Result<(ObjectChunk, &'a [u8]), Error>
Read the next complete piece without opening or copying it. A reader lacking this part’s key can skip the returned bytes while hashing them.
Sourcepub fn tail(&mut self, tail: &HeaderTail) -> Result<Vec<u8>, Error>
pub fn tail(&mut self, tail: &HeaderTail) -> Result<Vec<u8>, Error>
Write the part roots and header signature, only right after the header.
Sourcepub fn signature(&mut self, signature: &Signature) -> Result<[u8; 64], Error>
pub fn signature(&mut self, signature: &Signature) -> Result<[u8; 64], Error>
Write a signature only after every declared chunk.