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>
impl<'a> JSBuffer<'a>
pub fn new(buffer: &'a [u8]) -> Self
sourcepub fn look_ahead_matches(&self, s: &[u8]) -> bool
pub fn look_ahead_matches(&self, s: &[u8]) -> bool
Check if the next few bytes match the provided bytes
sourcepub fn look_ahead_byte_matches(&self, b: u8) -> bool
pub fn look_ahead_byte_matches(&self, b: u8) -> bool
Check if the next byte matches a single byte provided
sourcepub fn skip(&mut self, count: usize)
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
pub fn skip_back(&mut self, count: usize)
sourcepub fn skip_bytes(&mut self, count: usize)
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
sourcepub fn at_whitespace(&mut self) -> bool
pub fn at_whitespace(&mut self) -> bool
check if current char is a valid js whitespace character
sourcepub fn at_new_line(&mut self) -> bool
pub fn at_new_line(&mut self) -> bool
Check of the look ahead character is a valid js new line character
sourcepub fn at_decimal(&self) -> bool
pub fn at_decimal(&self) -> bool
check if the look ahead character is a number
between 0
and 9
, inclusive
sourcepub fn at_octal(&self) -> bool
pub fn at_octal(&self) -> bool
check if the look ahead character is a number
between 0
and 7
, inclusive
sourcepub fn at_hex(&self) -> bool
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
sourcepub fn peek_char(&mut self) -> Option<char>
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
sourcepub fn skip_back_bytes(&mut self, count: usize)
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)