StRingBuffer

Struct StRingBuffer 

Source
pub struct StRingBuffer<const SIZE: usize> { /* private fields */ }
Expand description

An implementation of StringBuffer using const generics to store its data on the stack.

Implementations§

Source§

impl<const SIZE: usize> StRingBuffer<SIZE>

Source

pub const fn new() -> Self

Creates a new StRingBuffer on the stack using the const generic size.

Trait Implementations§

Source§

impl<const SIZE: usize> Clone for StRingBuffer<SIZE>

Source§

fn clone(&self) -> StRingBuffer<SIZE>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const SIZE: usize> Debug for StRingBuffer<SIZE>

Source§

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

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

impl<const SIZE: usize> Display for StRingBuffer<SIZE>

Source§

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

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

impl<const SIZE: usize> From<[u8; SIZE]> for StRingBuffer<SIZE>

Source§

fn from(data: [u8; SIZE]) -> Self

Converts to this type from the input type.
Source§

impl<const SIZE: usize> Hash for StRingBuffer<SIZE>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<const SIZE: usize> IntoIterator for StRingBuffer<SIZE>

Source§

type Item = char

The type of the elements being iterated over.
Source§

type IntoIter = BufferIterator<StRingBuffer<SIZE>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<const SIZE: usize> Ord for StRingBuffer<SIZE>

Source§

fn cmp(&self, other: &StRingBuffer<SIZE>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<const SIZE: usize> PartialEq for StRingBuffer<SIZE>

Source§

fn eq(&self, other: &StRingBuffer<SIZE>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const SIZE: usize> PartialOrd for StRingBuffer<SIZE>

Source§

fn partial_cmp(&self, other: &StRingBuffer<SIZE>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<const SIZE: usize> StringBuffer for StRingBuffer<SIZE>

Source§

fn push_char(&mut self, c: char)

Adds a char to the buffer. Overwrites the start if the buffer is full. Read more
Source§

fn pop(&mut self) -> Option<char>

Remove a char from the buffer if one exists. Returns None if the buffer is empty.
Source§

fn pop_front(&mut self) -> Option<char>

Remove a char from the front of the buffer if one exists. Returns None if the buffer is empty.
Source§

fn try_push_char(&mut self, c: char) -> Result<usize, StringBufferError>

Tries to push the given character into the buffer. Will return Ok(c.bytes_len) if the write succeeded. If there is not enough room for the char or the buffer is full then Err(NotEnoughSpaceForChar) or Err(BufferFull) is returned respectively. Read more
Source§

fn push_str(&mut self, s: &str)

Adds a &str to the buffer. Overwrites the start if the buffer is full. Read more
Source§

fn try_push_some(&mut self, s: &str) -> Result<usize, StringBufferError>

Will push as many chars as will fit into the existing space of the buffer. Will not overwrite any existing data. Read more
Source§

fn as_slices(&self) -> (&str, &str)

Get a reference to the two buffer segments in order. Read more
Source§

fn align(&mut self)

Copies data as required to make the head the start of the buffer. This allocates a temporary buffer the size of the smaller &str given by as_slices. Read more
Source§

fn align_no_alloc(&mut self)

Aligns the head of the buffer to the start via rotation. Compared to align this function does not allocate any memory; however, it works in O(buffer.len()) time. Read more
Source§

fn len(&self) -> usize

Returns the length of this buffer, in bytes, not chars or graphemes Read more
Source§

fn is_empty(&self) -> bool

Returns true if there is no data in the buffer.
Source§

fn capacity(&self) -> usize

The number of bytes this buffer can hold. Not the number of chars or graphemes. Read more
Source§

fn remaining_size(&self) -> usize

Convenience function to return the number of bytes remaining in the buffer before data is overwritten. This is roughly equivalent to self.capacity() - self.len(), but takes into account any padding required along the edge of the buffer.
Source§

fn clear(&mut self)

Empties the buffer
Source§

fn try_push_all(&mut self, s: &str) -> Result<(), StringBufferError>

Try to push the entire string into the buffer. If the string is too long or the buffer is full then nothing is written and Err(NotEnoughSpaceForStr) or Err(BufferFull) is returned respectively. Read more
Source§

fn chars(&self) -> Chain<Chars<'_>, Chars<'_>>

Returns an iterator over the characters in the buffer. This includes both slices, in order, if the buffer is currently split. Read more
Source§

impl<const SIZE: usize> Write for StRingBuffer<SIZE>

Source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
Source§

fn write_char(&mut self, c: char) -> Result

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more
Source§

impl<const SIZE: usize> Copy for StRingBuffer<SIZE>

Source§

impl<const SIZE: usize> Eq for StRingBuffer<SIZE>

Source§

impl<const SIZE: usize> StructuralPartialEq for StRingBuffer<SIZE>

Auto Trait Implementations§

§

impl<const SIZE: usize> Freeze for StRingBuffer<SIZE>

§

impl<const SIZE: usize> RefUnwindSafe for StRingBuffer<SIZE>

§

impl<const SIZE: usize> Send for StRingBuffer<SIZE>

§

impl<const SIZE: usize> Sync for StRingBuffer<SIZE>

§

impl<const SIZE: usize> Unpin for StRingBuffer<SIZE>

§

impl<const SIZE: usize> UnwindSafe for StRingBuffer<SIZE>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.