pub struct StatusListInternal { /* private fields */ }Expand description
A Status List intended to be used by the Status List Owners to manipulate the list.
It consists of a StatusList and its size, which is needed to
successfully manipulate the list.
This provides functionalities to create a new empty list, load an existing list, append new elements to the list and update the existing elements.
§Note
This is only intended to be used by the Status List Owners, as they are the
ones that are changing the list. All other parties should use the
StatusList, which will enable them to read the list at a specific index.
It is also what they will receive after fetching the list from the owner.
Implementations§
Source§impl StatusListInternal
impl StatusListInternal
Sourcepub fn new(bits: StatusBits, aggregation_uri: Option<UriBuf>) -> Self
pub fn new(bits: StatusBits, aggregation_uri: Option<UriBuf>) -> Self
Initializes a new empty StatusList.
Sourcepub fn status_list(&self) -> &StatusList
pub fn status_list(&self) -> &StatusList
Returns a reference to the underlying StatusList.
Sourcepub fn new_from_parts(
bits: StatusBits,
lst: Vec<u8>,
aggregation_uri: Option<UriBuf>,
size: usize,
) -> Result<Self>
pub fn new_from_parts( bits: StatusBits, lst: Vec<u8>, aggregation_uri: Option<UriBuf>, size: usize, ) -> Result<Self>
Creates a new StatusList from its exact parts.
This function exists as a convenience for Status List Owners to be able to store the Status List field by field and load it later to utilize the implemented functionalities.
§Errors
The size argument MUST point to the last byte of the lst and
all the statuses from there until the end of the last byte (and
consequently the lst itself) need to be set to 0, otherwise, the
Error::InconsistentSize is returned.
§Note
The size argument can still be abused to rewrite all the trailing
statuses set to 0 in the last byte, but there is no way to add a
check for that, so the caller needs not to mess with the size in order
to prevent bugs.
Sourcepub fn push(&mut self, status: u8) -> Result<usize>
pub fn push(&mut self, status: u8) -> Result<usize>
Adds a new status entry at the end of the Status List and returns an index of that entry within the list.
§Errors
If the provided status takes more bits than specified with
StatusBits, the method results in the Error::StatusTooLarge.
Sourcepub fn update(&mut self, index: usize, status: u8) -> Result<()>
pub fn update(&mut self, index: usize, status: u8) -> Result<()>
Updates the status at the given index to the provided status value.
§Errors
The method results in the Error::IndexOutOfBounds error if the
index is out of bounds, and the Error::StatusTooLarge error if the
status does not fit in the correct amount of bits.