Struct ress::JSBuffer

source ·
pub struct JSBuffer<'a> {
    pub buffer: &'a [u8],
    pub idx: usize,
    pub len: usize,
}

Fields§

§buffer: &'a [u8]§idx: usize§len: usize

Implementations§

source§

impl<'a> JSBuffer<'a>

Re-implementation of the std::str::Chars logic

source

pub fn next_char(&mut self) -> Option<char>

source

pub fn prev_char(&mut self) -> Option<char>

source§

impl<'a> JSBuffer<'a>

source

pub fn new(buffer: &'a [u8]) -> Self

source

pub fn at_end(&self) -> bool

Check if the buffer is at or past the end of the bytes provided

source

pub fn look_ahead_matches(&self, s: &[u8]) -> bool

Check if the next few bytes match the provided bytes

source

pub fn look_ahead_byte_matches(&self, b: u8) -> bool

Check if the next byte matches a single byte provided

source

pub fn skip(&mut self, count: usize)

Skip the number of characters provided returning the number of bytes skipped note: these are full unicode characters, not just bytes

source

pub fn skip_back(&mut self, count: usize)

source

pub fn skip_bytes(&mut self, count: usize)

Skip a single byte note: this can cause the buffer to become unaligned be sure to always know the character you are skipping is 1 byte wide or use skip instead when unsure

source

pub fn at_whitespace(&mut self) -> bool

check if current char is a valid js whitespace character

source

pub fn at_new_line(&mut self) -> bool

Check of the look ahead character is a valid js new line character

source

pub fn at_binary(&self) -> bool

check if the look ahead character is 0 or 1

source

pub fn at_decimal(&self) -> bool

check if the look ahead character is a number between 0 and 9, inclusive

source

pub fn at_octal(&self) -> bool

check if the look ahead character is a number between 0 and 7, inclusive

source

pub fn at_hex(&self) -> bool

check if the look ahead character is a number between 0 and 9 or a and f or A and F, inclusive

source

pub fn peek_char(&mut self) -> Option<char>

Peek forward 1 char with out updating the idx to this new position.

note: this will still cost the same amount of work as next_char but cleans up the book keeping for you

source

pub fn skip_back_bytes(&mut self, count: usize)

Skip backwards a number of bytes note: this can cause the buffer to become unaligned be sure to always know the character you are skipping is [count] bytes wide or use skip instead when unsure the right width is skipped

Trait Implementations§

source§

impl<'a> Clone for JSBuffer<'a>

source§

fn clone(&self) -> JSBuffer<'a>

Returns a copy 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<'a> From<&'a str> for JSBuffer<'a>

source§

fn from(s: &'a str) -> JSBuffer<'_>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for JSBuffer<'a>

§

impl<'a> RefUnwindSafe for JSBuffer<'a>

§

impl<'a> Send for JSBuffer<'a>

§

impl<'a> Sync for JSBuffer<'a>

§

impl<'a> Unpin for JSBuffer<'a>

§

impl<'a> UnwindSafe for JSBuffer<'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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

§

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, U> TryFrom<U> for T
where 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 T
where 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.