pub struct ZeroCopyStr<'a> { /* private fields */ }Implementations§
Source§impl<'a> ZeroCopyStr<'a>
impl<'a> ZeroCopyStr<'a>
Sourcepub fn write_to(
str: &str,
bytes: &'a mut [u8],
) -> (ZeroCopyStr<'a>, &'a mut [u8])
pub fn write_to( str: &str, bytes: &'a mut [u8], ) -> (ZeroCopyStr<'a>, &'a mut [u8])
Writes the contents of a &str within the buffer provided.
Requires space for the str byte length + LEN_TYPE_SIZE length.
We also return a new reference pointing just after the end of the str written.
Panics if buffer is not large enough.
Sourcepub fn write_to_update<'o>(
str: &str,
bytes: &'o mut &'a mut [u8],
) -> ZeroCopyStr<'a>
pub fn write_to_update<'o>( str: &str, bytes: &'o mut &'a mut [u8], ) -> ZeroCopyStr<'a>
Writes the contents of a &str within the buffer provided.
Requires space for the str byte length + LEN_TYPE_SIZE length.
We also update the position of the reference to just after the end of the str.
Panics if buffer is not large enough.
Sourcepub fn read_from(bytes: &mut &'a [u8]) -> ZeroCopyStr<'a>
pub fn read_from(bytes: &mut &'a [u8]) -> ZeroCopyStr<'a>
Zero-copy deserializes bytes into ZeroCopyStr. Update the reference to point
We also update the position of the reference to just after the end of the str.
Panics if the buffer does not hold the proper data.
Sourcepub fn serialized_size(&self) -> usize
pub fn serialized_size(&self) -> usize
Total serialized size: str bytes + len bytes
Trait Implementations§
Source§impl<'a> Clone for ZeroCopyStr<'a>
impl<'a> Clone for ZeroCopyStr<'a>
Source§fn clone(&self) -> ZeroCopyStr<'a>
fn clone(&self) -> ZeroCopyStr<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a> Debug for ZeroCopyStr<'a>
impl<'a> Debug for ZeroCopyStr<'a>
Source§impl<'a> From<&'a str> for ZeroCopyStr<'a>
impl<'a> From<&'a str> for ZeroCopyStr<'a>
Source§impl<'a> PartialEq<&str> for ZeroCopyStr<'a>
impl<'a> PartialEq<&str> for ZeroCopyStr<'a>
Source§impl<'a> PartialEq for ZeroCopyStr<'a>
impl<'a> PartialEq for ZeroCopyStr<'a>
impl<'a> Copy for ZeroCopyStr<'a>
impl<'a> StructuralPartialEq for ZeroCopyStr<'a>
Auto Trait Implementations§
impl<'a> Freeze for ZeroCopyStr<'a>
impl<'a> RefUnwindSafe for ZeroCopyStr<'a>
impl<'a> Send for ZeroCopyStr<'a>
impl<'a> Sync for ZeroCopyStr<'a>
impl<'a> Unpin for ZeroCopyStr<'a>
impl<'a> UnwindSafe for ZeroCopyStr<'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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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 more