pub struct FrameSlice<'frame> { /* private fields */ }Expand description
A borrowed reference to a part of the frame.
Implementations§
Source§impl<'frame> FrameSlice<'frame>
impl<'frame> FrameSlice<'frame>
Sourcepub fn new(frame: &'frame Bytes) -> Self
pub fn new(frame: &'frame Bytes) -> Self
Creates a new FrameSlice from a reference of a Bytes object.
This method is exposed to allow writing deserialization tests for custom types.
Sourcepub fn as_slice_mut(&mut self) -> &mut &'frame [u8] ⓘ
pub fn as_slice_mut(&mut self) -> &mut &'frame [u8] ⓘ
Returns a mutable reference to the subslice.
Sourcepub fn as_original_frame_bytes(&self) -> &'frame Bytes
pub fn as_original_frame_bytes(&self) -> &'frame Bytes
Returns a reference to the Bytes object which encompasses the whole frame slice.
The Bytes object will usually be larger than the slice returned by FrameSlice::as_slice. If you wish to obtain a new Bytes object that points only to the subslice represented by the FrameSlice object, see FrameSlice::to_bytes.
Sourcepub fn to_bytes(&self) -> Bytes
pub fn to_bytes(&self) -> Bytes
Returns a new Bytes object which is a subslice of the original Bytes frame slice object.
Sourcepub fn read_cql_bytes(
&mut self,
) -> Result<Option<FrameSlice<'frame>>, LowLevelDeserializationError>
pub fn read_cql_bytes( &mut self, ) -> Result<Option<FrameSlice<'frame>>, LowLevelDeserializationError>
Reads and consumes a [bytes] item from the beginning of the frame,
returning a subslice that encompasses that item.
If the operation fails then the slice remains unchanged.
Sourcepub fn read_n_bytes(
&mut self,
count: usize,
) -> Result<Option<FrameSlice<'frame>>, LowLevelDeserializationError>
pub fn read_n_bytes( &mut self, count: usize, ) -> Result<Option<FrameSlice<'frame>>, LowLevelDeserializationError>
Reads and consumes a fixed number of bytes from the beginning of the frame, returning a subslice that encompasses them.
If this slice is empty, returns Ok(None).
Otherwise, if the slice does not contain enough data, it returns Err.
If the operation fails then the slice remains unchanged.
Trait Implementations§
Source§impl<'frame> Clone for FrameSlice<'frame>
impl<'frame> Clone for FrameSlice<'frame>
Source§fn clone(&self) -> FrameSlice<'frame>
fn clone(&self) -> FrameSlice<'frame>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'frame> Debug for FrameSlice<'frame>
impl<'frame> Debug for FrameSlice<'frame>
Source§impl<'frame> From<FrameSlice<'frame>> for BytesSequenceIterator<'frame>
impl<'frame> From<FrameSlice<'frame>> for BytesSequenceIterator<'frame>
Source§fn from(slice: FrameSlice<'frame>) -> Self
fn from(slice: FrameSlice<'frame>) -> Self
impl<'frame> Copy for FrameSlice<'frame>
Auto Trait Implementations§
impl<'frame> Freeze for FrameSlice<'frame>
impl<'frame> RefUnwindSafe for FrameSlice<'frame>
impl<'frame> Send for FrameSlice<'frame>
impl<'frame> Sync for FrameSlice<'frame>
impl<'frame> Unpin for FrameSlice<'frame>
impl<'frame> UnwindSafe for FrameSlice<'frame>
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§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 more