Anchor

Struct Anchor 

Source
pub struct Anchor<'a, 'b, T> {
    pub iref: &'a mut InputRef<'b, T>,
    pub index: usize,
}
Expand description

Anchoring the current index of the cursor. Restore index when dropped.

Fields§

§iref: &'a mut InputRef<'b, T>

Reference of InputRef.

§index: usize

The index which is used to restore the cursor when drop.

Implementations§

Source§

impl<'a, 'b, T> Anchor<'a, 'b, T>

Source

pub fn new(iref: &'a mut InputRef<'b, T>) -> Self

Create a new Anchor from InputRef.

Source

pub fn renew(&mut self)

Set the current index to the anchor.

Source

pub fn forget(self) -> &'a mut InputRef<'b, T>

Forget the anchor. The current index of the cursor is unchanged.

Source

pub fn range(&self) -> Range<usize>

Get the range of the start of the anchor to the current index.

Methods from Deref<Target = &'a mut InputRef<'b, T>>§

Source

pub fn scope_cursor_mut<O>( &mut self, jail: impl FnOnce(&mut CursorRef<'_, T>) -> O, ) -> O

Do something with a mutable reference of Cursor. This crate is safe if you can’t bring arguments to outside. I believe it is true.

Source

pub fn scope_cursor<O>(&self, jail: impl FnOnce(&CursorRef<'_, T>) -> O) -> O

Do something with a reference of Cursor. This crate is safe if you can’t bring arguments to outside. I believe it is true.

Source

pub fn read(&mut self) -> impl Future<Output = ()> + '_

Stop parsing until the buffer is extended.

Source

pub fn read_n(&mut self, at_least: usize) -> impl Future<Output = ()> + '_

Stop parsing until the buf.len() >= index + at_least.

Trait Implementations§

Source§

impl<'a, 'b, T> Deref for Anchor<'a, 'b, T>

Source§

type Target = &'a mut InputRef<'b, T>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a, 'b, T> DerefMut for Anchor<'a, 'b, T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'a, 'b, T> Drop for Anchor<'a, 'b, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, 'b, T> Freeze for Anchor<'a, 'b, T>

§

impl<'a, 'b, T> !RefUnwindSafe for Anchor<'a, 'b, T>

§

impl<'a, 'b, T> !Send for Anchor<'a, 'b, T>

§

impl<'a, 'b, T> !Sync for Anchor<'a, 'b, T>

§

impl<'a, 'b, T> Unpin for Anchor<'a, 'b, T>

§

impl<'a, 'b, T> !UnwindSafe for Anchor<'a, 'b, 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.