SessionOps

Struct SessionOps 

#[repr(transparent)]
pub struct SessionOps([u8]);
Expand description

A validated byte slice known to contain a well-formed sequence of encoded SessionOps.

This is the borrowed counterpart of super::SessionOpsBuf. Use SessionOps::new to validate untrusted bytes, then iterate with SessionOps::iter (or via IntoIterator) or replay them with SessionOps::apply.

Tuple Fields§

§0: [u8]

Implementations§

§

impl SessionOps

pub fn new(data: &[u8]) -> Result<&Self, OpDecodeError>

Validates data and return it as a SessionOps reference.

§Errors

Returns OpDecodeError if any embedded op cannot be decoded.

pub const unsafe fn new_unchecked(data: &[u8]) -> &Self

Wraps data as a SessionOps reference without validation.

§Safety

data must be a complete, well-formed sequence of encoded SessionOps. That is, iterating it through Reader and SessionOp::decode must succeed for every op until the reader is empty. Violating this invariant is undefined behaviour because downstream code (notably SessionOpsIter) relies on it to elide error handling.

pub const fn as_bytes(&self) -> &[u8]

Returns the raw encoded bytes backing this slice.

pub const fn is_empty(&self) -> bool

Returns true if there are no operations.

pub const fn iter(&self) -> SessionOpsIter<'_>

Returns an iterator over the operations in this buffer.

pub fn apply<S: SessionState>(&self, session: &mut S)

Apply every operation in this buffer to session, in order.

Trait Implementations§

§

impl Debug for SessionOps

§

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

Formats the value using the given formatter. Read more
§

impl<'a> IntoIterator for &'a SessionOps

§

type Item = SessionOp<'a>

The type of the elements being iterated over.
§

type IntoIter = SessionOpsIter<'a>

Which kind of iterator are we turning this into?
§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

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