pub struct Staging<'a, S: SlotStore> { /* private fields */ }Expand description
A slot open for an image, with the manifest’s promises still to be met.
The slot’s record is only written once the image has been verified whole, so an interrupted transfer leaves a slot that is never bootable rather than one holding half an image.
Implementations§
Source§impl<S: SlotStore> Staging<'_, S>
impl<S: SlotStore> Staging<'_, S>
Sourcepub fn write(&mut self, chunk: &[u8]) -> Result<()>
pub fn write(&mut self, chunk: &[u8]) -> Result<()>
Takes the next piece of the image.
§Arguments
chunk- the next bytes of the image, in order.
§Returns
Ok(()) once the chunk is hashed and stored.
§Errors
Returns Refusal::Size if more bytes arrive than the manifest declared,
or Refusal::SlotTooSmall if the slot cannot take them.
Sourcepub fn progress(&self) -> (u32, u32)
pub fn progress(&self) -> (u32, u32)
Reports how much of the image has arrived.
§Returns
The bytes stored so far and the total the manifest declares.
Sourcepub fn finish(self) -> Result<u8>
pub fn finish(self) -> Result<u8>
Finishes the image and marks the slot bootable if it matched.
§Returns
The slot now holding a staged image.
§Errors
Returns Refusal::Size or Refusal::Digest if the image is not the
one the manifest described, leaving the slot unbootable.