Struct rsonpath::input::owned::OwnedBytes
source · pub struct OwnedBytes { /* private fields */ }Expand description
Input into a query engine.
Implementations§
source§impl OwnedBytes
impl OwnedBytes
sourcepub fn as_borrowed(&self) -> BorrowedBytes<'_>
pub fn as_borrowed(&self) -> BorrowedBytes<'_>
Convert to BorrowedBytes.
sourcepub unsafe fn from_raw_parts(ptr: NonNull<u8>, size: usize) -> Self
pub unsafe fn from_raw_parts(ptr: NonNull<u8>, size: usize) -> Self
Create an instance of OwnedBytes from raw pointers.
Safety
This is highly unsafe, and requires similar invariants as stdlib’s Vec.
ptrmust have been allocated using the global allocator;ptrmust have been allocated with size equal tosize;- first
sizevalues thatptrpoints to must be correctly initialized instances ofu8. - the
sizemust be not more thanisize::MAX; ptrmust be aligned to theMAX_BLOCK_SIZEboundary;sizemust be divisible byMAX_BLOCK_SIZE.
Ownership of ptr is transferred to the resulting instance. You must ensure
there are no other mutable references to its contents and that the memory
is not deallocated.
sourcepub fn new<T: AsRef<[u8]>>(src: &T) -> Result<Self, InputError>
pub fn new<T: AsRef<[u8]>>(src: &T) -> Result<Self, InputError>
Copy a buffer of bytes and create a proper OwnedBytes instance.
The contents of the buffer will be copied and might be padded to
the MAX_BLOCK_SIZE boundary.
Errors
If the length of the buffer plus
the padding exceeds the system limit of isize::MAX, an InputError::AllocationSizeExceeded
error will be raised.
sourcepub unsafe fn new_unchecked<T: AsRef<[u8]>>(src: &T) -> Self
pub unsafe fn new_unchecked<T: AsRef<[u8]>>(src: &T) -> Self
Create a new instance of OwnedBytes from a buffer satisfying
all invariants.
Safety
The invariants are assumed, not checked. You must ensure that the buffer passed to this function:
- has length not exceeding the system cap of isize::MAX;
- is aligned to the
MAX_BLOCK_SIZEboundary; - has length divisible by
MAX_BLOCK_SIZE.
Trait Implementations§
source§impl Drop for OwnedBytes
impl Drop for OwnedBytes
source§impl<'a> From<&BorrowedBytes<'a>> for OwnedBytes
impl<'a> From<&BorrowedBytes<'a>> for OwnedBytes
source§fn from(value: &BorrowedBytes<'_>) -> Self
fn from(value: &BorrowedBytes<'_>) -> Self
source§impl Input for OwnedBytes
impl Input for OwnedBytes
§type BlockIterator<'a, 'r, const N: usize, R> = BorrowedBytesBlockIterator<'a, 'r, N, R>
where
R: InputRecorder<&'a [u8]> + 'r
type BlockIterator<'a, 'r, const N: usize, R> = BorrowedBytesBlockIterator<'a, 'r, N, R> where R: InputRecorder<&'a [u8]> + 'r
iter_blocks, parameterized
by the lifetime of source input and the size of the block.source§fn iter_blocks<'a, 'r, R, const N: usize>(
&'a self,
recorder: &'r R
) -> Self::BlockIterator<'a, 'r, N, R>where
R: InputRecorder<&'a [u8]>,
fn iter_blocks<'a, 'r, R, const N: usize>( &'a self, recorder: &'r R ) -> Self::BlockIterator<'a, 'r, N, R>where R: InputRecorder<&'a [u8]>,
N of the input.
N has to be a power of two larger than 1.source§fn seek_backward(&self, from: usize, needle: u8) -> Option<usize>
fn seek_backward(&self, from: usize, needle: u8) -> Option<usize>
needle in the input,
starting from from and looking back. Returns the index
of the first occurrence or None if the needle was not found.source§fn seek_forward<const N: usize>(
&self,
from: usize,
needles: [u8; N]
) -> Result<Option<(usize, u8)>, InputError>
fn seek_forward<const N: usize>( &self, from: usize, needles: [u8; N] ) -> Result<Option<(usize, u8)>, InputError>
needles in the input,
starting from from and looking forward. Returns the index
of the first occurrence and the needle found, or None if none of the needles were not found. Read moresource§fn seek_non_whitespace_forward(
&self,
from: usize
) -> Result<Option<(usize, u8)>, InputError>
fn seek_non_whitespace_forward( &self, from: usize ) -> Result<Option<(usize, u8)>, InputError>
from. Returns a pair: the index of first such byte,
and the byte itself; or None if no non-whitespace characters
were found. Read moresource§fn seek_non_whitespace_backward(&self, from: usize) -> Option<(usize, u8)>
fn seek_non_whitespace_backward(&self, from: usize) -> Option<(usize, u8)>
from and looking back. Returns a pair:
the index of first such byte, and the byte itself;
or None if no non-whitespace characters were found.source§fn find_member(
&self,
from: usize,
label: &JsonString
) -> Result<Option<usize>, InputError>
fn find_member( &self, from: usize, label: &JsonString ) -> Result<Option<usize>, InputError>
member
(comparing bitwise, including double quotes delimiters)
starting from from. Returns the index of the first occurrence,
or None if no occurrence was found. Read moresource§fn is_member_match(&self, from: usize, to: usize, label: &JsonString) -> bool
fn is_member_match(&self, from: usize, to: usize, label: &JsonString) -> bool
from (inclusive)
and to (exclusive) matches the member (comparing bitwise,
including double quotes delimiters). Read more