Skip to main content

Cut

Struct Cut 

Source
pub struct Cut<'a> { /* private fields */ }
Expand description

A cursor over a frozen body.

Every read either moves the cursor forward and answers, or answers Broken::Short and leaves the cursor wherever it was. There is no way to go backwards, because nothing that reads one of these needs to: a form is written in the order it is read.

Implementations§

Source§

impl<'a> Cut<'a>

Source

pub const fn new(bytes: &'a [u8]) -> Cut<'a>

A cursor at the start of bytes.

Source

pub fn byte(&mut self) -> Result<u8, Broken>

The next byte.

Source

pub fn uint(&mut self) -> Result<u64, Broken>

The next LEB128 number.

Ten groups at most, which is what a u64 takes, so a payload of nothing but continuation bits cannot spin here.

Source

pub fn int(&mut self) -> Result<i64, Broken>

The next zigzagged number.

Source

pub fn f64(&mut self) -> Result<f64, Broken>

The next double, from its eight raw bytes.

Source

pub fn take(&mut self, n: usize) -> Result<&'a [u8], Broken>

The next n bytes.

Source

pub fn bytes(&mut self) -> Result<&'a [u8], Broken>

The next length prefixed byte string.

Source

pub const fn rest(&self) -> &'a [u8]

Everything from here to the end, which is what a form that ends in one blob wants.

A blob at the end of a form needs no length, because the frozen body is its own length. That is the whole reason the two forms that hand back a structure Redis already knows how to lay out cost one byte of overhead.

Auto Trait Implementations§

§

impl<'a> Freeze for Cut<'a>

§

impl<'a> RefUnwindSafe for Cut<'a>

§

impl<'a> Send for Cut<'a>

§

impl<'a> Sync for Cut<'a>

§

impl<'a> Unpin for Cut<'a>

§

impl<'a> UnsafeUnpin for Cut<'a>

§

impl<'a> UnwindSafe for Cut<'a>

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.