Skip to main content

ShiftBuffer

Struct ShiftBuffer 

Source
pub struct ShiftBuffer<T> { /* private fields */ }

Implementations§

Source§

impl<T: Default + Copy> ShiftBuffer<T>

Source

pub fn new(init_size: usize) -> Self

Source

pub fn shrink(&mut self, n: usize) -> Pointer

Moves the lower end of the window by n.

Source

pub fn extend(&mut self, n: usize) -> Pointer

Moves the upper end of the window by n.

Source

pub fn make_room(&mut self) -> &mut [T]

Make room in the buffer for more data.

If the upper end of the window is not at the stop position of the internal buffer, this method has no effect on the state of the buffer.

Otherwise, it performs either of two operations: if the lower end is at the beginning of the buffer (the window covers the entire buffer), the buffer is extended. Otherwise, the buffer is shifted; i.e., all entries prior to the lower end are discarded and the content is moved to the beginning of the buffer.

In all cases, the return value of this method is the same as for ShiftBuffer::free.

Source

pub fn shift(&mut self)

Source

pub fn free(&mut self) -> &mut [T]

Source

pub fn lower(&self) -> Pointer

Source

pub fn upper(&self) -> Pointer

Source

pub fn relative_pos(&self, p: Pointer) -> usize

Source

pub fn clone_window(&self) -> ShiftBuffer<T>

Create a shift buffer that contains a copy of the current window.

Trait Implementations§

Source§

impl<T: Default + Copy> Index<Pointer> for ShiftBuffer<T>

Source§

type Output = T

The returned type after indexing.
Source§

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

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

impl<T: Default + Copy> Index<Range<Pointer>> for ShiftBuffer<T>

Source§

type Output = [T]

The returned type after indexing.
Source§

fn index(&self, r: Range<Pointer>) -> &Self::Output

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

impl<T: Default + Copy> IndexMut<Pointer> for ShiftBuffer<T>

Source§

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

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

Auto Trait Implementations§

§

impl<T> Freeze for ShiftBuffer<T>

§

impl<T> RefUnwindSafe for ShiftBuffer<T>
where T: RefUnwindSafe,

§

impl<T> Send for ShiftBuffer<T>
where T: Send,

§

impl<T> Sync for ShiftBuffer<T>
where T: Sync,

§

impl<T> Unpin for ShiftBuffer<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for ShiftBuffer<T>

§

impl<T> UnwindSafe for ShiftBuffer<T>
where T: UnwindSafe,

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.