#[repr(C)]pub struct View {
pub length: u32,
pub prefix: u32,
pub buffer_idx: u32,
pub offset: u32,
}
Expand description
A reference to a set of bytes.
If length <= 12
, these bytes are inlined over the prefix
, buffer_idx
and offset
fields.
If length > 12
, these fields specify a slice of a buffer.
Fields§
§length: u32
The length of the string/bytes.
prefix: u32
First 4 bytes of string/bytes data.
buffer_idx: u32
The buffer index.
offset: u32
The offset into the buffer.
Implementations§
Source§impl View
impl View
pub const MAX_INLINE_SIZE: u32 = 12u32
pub fn as_u128(self) -> u128
Sourcepub unsafe fn new_inline_unchecked(bytes: &[u8]) -> Self
pub unsafe fn new_inline_unchecked(bytes: &[u8]) -> Self
Create a new inline view without verifying the length
§Safety
It needs to hold that bytes.len() <= View::MAX_INLINE_SIZE
.
Sourcepub fn new_inline(bytes: &[u8]) -> Self
pub fn new_inline(bytes: &[u8]) -> Self
Sourcepub unsafe fn new_noninline_unchecked(
bytes: &[u8],
buffer_idx: u32,
offset: u32,
) -> Self
pub unsafe fn new_noninline_unchecked( bytes: &[u8], buffer_idx: u32, offset: u32, ) -> Self
pub fn new_from_bytes(bytes: &[u8], buffer_idx: u32, offset: u32) -> Self
Sourcepub unsafe fn get_slice_unchecked<'a>(
&'a self,
buffers: &'a [Buffer<u8>],
) -> &'a [u8] ⓘ
pub unsafe fn get_slice_unchecked<'a>( &'a self, buffers: &'a [Buffer<u8>], ) -> &'a [u8] ⓘ
Constructs a byteslice from this view.
§Safety
Assumes that this view is valid for the given buffers.
Sourcepub fn extend_with_inlinable_strided(
views: &mut Vec<Self>,
src: &[u8],
width: u8,
)
pub fn extend_with_inlinable_strided( views: &mut Vec<Self>, src: &[u8], width: u8, )
Extend a Vec<View>
with inline views slices of src
with width
.
This tries to use SIMD to optimize the copying and can be massively faster than doing a
views.extend(src.chunks_exact(width).map(View::new_inline))
.
§Panics
This function panics if src.len()
is not divisible by width
, width > View::MAX_INLINE_SIZE
or width == 0
.
Trait Implementations§
Source§impl From<Bytes16Alignment4> for View
impl From<Bytes16Alignment4> for View
Source§fn from(value: Bytes16Alignment4) -> Self
fn from(value: Bytes16Alignment4) -> Self
Source§impl From<View> for Bytes16Alignment4
impl From<View> for Bytes16Alignment4
Source§impl MinMax for View
impl MinMax for View
fn nan_min_lt(&self, _other: &Self) -> bool
fn nan_max_lt(&self, _other: &Self) -> bool
fn min_propagate_nan(self, other: Self) -> Self
fn max_propagate_nan(self, other: Self) -> Self
fn min_ignore_nan(self, other: Self) -> Self
fn max_ignore_nan(self, other: Self) -> Self
Source§impl NativeType for View
impl NativeType for View
Source§const PRIMITIVE: PrimitiveType = PrimitiveType::UInt128
const PRIMITIVE: PrimitiveType = PrimitiveType::UInt128
PrimitiveType
.Source§type Bytes = [u8; 16]
type Bytes = [u8; 16]
[u8; N]
where N = size_of::<T>
.Source§type AlignedBytes = Bytes16Alignment4
type AlignedBytes = Bytes16Alignment4
Source§fn to_le_bytes(&self) -> Self::Bytes
fn to_le_bytes(&self) -> Self::Bytes
Source§fn to_be_bytes(&self) -> Self::Bytes
fn to_be_bytes(&self) -> Self::Bytes
Source§fn from_le_bytes(bytes: Self::Bytes) -> Self
fn from_le_bytes(bytes: Self::Bytes) -> Self
Source§fn from_be_bytes(bytes: Self::Bytes) -> Self
fn from_be_bytes(bytes: Self::Bytes) -> Self
impl AlignedBytesCast<Bytes16Alignment4> for View
impl Copy for View
impl Pod for View
Auto Trait Implementations§
impl Freeze for View
impl RefUnwindSafe for View
impl Send for View
impl Sync for View
impl Unpin for View
impl UnwindSafe for View
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> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self
.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
)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string()
Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString
. Read more