Struct lib0::decoding::Cursor

source ·
pub struct Cursor<'a> {
    pub buf: &'a [u8],
    pub next: usize,
}

Fields§

§buf: &'a [u8]§next: usize

Implementations§

source§

impl<'a> Cursor<'a>

source

pub fn new(buf: &'a [u8]) -> Cursor<'a>

source

pub fn has_content(&self) -> bool

Trait Implementations§

source§

impl<'a> Default for Cursor<'a>

source§

fn default() -> Cursor<'a>

Returns the “default value” for a type. Read more
source§

impl<'a, R> From<&'a R> for Cursor<'a>where R: AsRef<[u8]>,

source§

fn from(buf: &'a R) -> Self

Converts to this type from the input type.
source§

impl<'a> Read for Cursor<'a>

source§

fn read_exact(&mut self, len: usize) -> Result<&[u8], Error>

Take a slice of the next len bytes and advance the position by len.

source§

fn read_u8(&mut self) -> Result<u8, Error>

Read a single byte.

source§

fn read_buf(&mut self) -> Result<&[u8], Error>

Read a variable length buffer.
source§

fn read_u16(&mut self) -> Result<u16, Error>

Read 2 bytes as unsigned integer
source§

fn read_u32(&mut self) -> Result<u32, Error>

Read 4 bytes as unsigned integer
source§

fn read_u32_be(&mut self) -> Result<u32, Error>

Read 4 bytes as unsigned integer in big endian order. (most significant byte first)
source§

fn read_var<T: VarInt>(&mut self) -> Result<T, Error>

Read unsigned integer with variable length. Read more
source§

fn read_var_signed<T: SignedVarInt>(&mut self) -> Result<Signed<T>, Error>

Read unsigned integer with variable length. Read more
source§

fn read_string(&mut self) -> Result<&str, Error>

Read string of variable length.
source§

fn read_f32(&mut self) -> Result<f32, Error>

Read float32 in big endian order
source§

fn read_f64(&mut self) -> Result<f64, Error>

Read float64 in big endian order
source§

fn read_i64(&mut self) -> Result<i64, Error>

Read BigInt64 in big endian order
source§

fn read_u64(&mut self) -> Result<u64, Error>

read BigUInt64 in big endian order

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Cursor<'a>

§

impl<'a> Send for Cursor<'a>

§

impl<'a> Sync for Cursor<'a>

§

impl<'a> Unpin for Cursor<'a>

§

impl<'a> UnwindSafe for Cursor<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.