StatusListInternal

Struct StatusListInternal 

Source
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

Source

pub fn new(bits: StatusBits, aggregation_uri: Option<UriBuf>) -> Self

Initializes a new empty StatusList.

Source

pub fn size(&self) -> usize

Returns the number of recorded statuses in the Status List.

Source

pub fn status_list(&self) -> &StatusList

Returns a reference to the underlying StatusList.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for StatusListInternal

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<StatusListInternal> for StatusList

Source§

fn from(list: StatusListInternal) -> Self

Converts to this type from the input type.

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