Skip to main content

Session

Struct Session 

Source
pub struct Session<'a, T> { /* private fields */ }

Implementations§

Source§

impl<'a, T: Copy> Session<'a, T>

Source

pub fn next_slice(&mut self) -> SliceIndex

Create and return a new session key from the current session. This means the current session is now pointing to the end of the buffer.

Source

pub fn insert(&mut self, pos: usize, value: T)

Insert a value into the buffer

Source

pub fn last(&self) -> Option<&T>

Reference to the last value in the buffer, regardless of where the session is pointing.

Source

pub fn push(&mut self, value: T)

Push a value to the buffer.

§Panics

This will panic if there is no slice keys in the buffer. One can be created with self.next_slice()

Source

pub fn pop(&mut self) -> Option<T>

Pop a value from the buffer. This is fine as a session is always referring to the end of the underlying buffer.

Source

pub fn extend(&mut self, iter: impl IntoIterator<Item = T>)

Extend the buffer with the contents from the iterator

Source

pub fn tail_drain(&mut self, size: u32)

Remove N elements from the end of the buffer

Source

pub fn slice(&self, index: SliceIndex) -> &[T]

Get a slice of data from the underlying buffer

Source

pub fn slice_mut(&mut self, index: SliceIndex) -> &mut [T]

Get a slice of mutable data from the underlying buffer

Source

pub fn len(&self) -> u32

Length of the session buffer, not the total buffer

Source

pub fn is_empty(&self) -> bool

It’s empty?

Source

pub fn truncate(&mut self, key: SliceIndex, index: usize)

Trait Implementations§

Source§

impl<'a, T: Debug> Debug for Session<'a, T>

Source§

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

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

impl<'a, T: Copy> Index<usize> for Session<'a, T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, T: Copy> IndexMut<usize> for Session<'a, T>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<'a, T> !UnwindSafe for Session<'a, T>

§

impl<'a, T> Freeze for Session<'a, T>

§

impl<'a, T> RefUnwindSafe for Session<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for Session<'a, T>
where T: Send,

§

impl<'a, T> Sync for Session<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for Session<'a, T>

§

impl<'a, T> UnsafeUnpin for Session<'a, T>

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