Struct mz_repr::row::RowRef

source ·
#[repr(transparent)]
pub struct RowRef { data: [u8], }
Expand description

A wrapper around a byte slice that guarantees the data are row-formatted.

This type exists to allow row-formatted data to be stored in types that need not contain a Row, for example large contiguous [u8] allocations. It is not expected that most users will use this type, especially as its only constructor is unsafe.

Fields§

§data: [u8]

Implementations§

source§

impl RowRef

source

pub unsafe fn from_bytes_unchecked(data: &[u8]) -> &Self

Construct a RowRef from a byte slice.

Safety

This method is unsafe because if the byte slice is not a valid row encoding, then unpacking its contents can cause undefined behavior.

source

pub fn unpack(&self) -> Vec<Datum<'_>>

Unpack self into a Vec<Datum> for efficient random access.

source

pub fn unpack_first(&self) -> Datum<'_>

Return the first Datum in self

Panics if the Row is empty.

source

pub fn iter(&self) -> DatumListIter<'_>

Iterate the Datum elements of the Row.

source

pub fn data(&self) -> &[u8]

For debugging only

source

pub fn is_empty(&self) -> bool

True iff there is no data in this Row

Trait Implementations§

source§

impl Debug for RowRef

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Debug representation using the internal datums

source§

impl Display for RowRef

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Display representation using the internal datums

source§

impl<'a> IntoIterator for &'a RowRef

§

type Item = Datum<'a>

The type of the elements being iterated over.
§

type IntoIter = DatumListIter<'a>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> DatumListIter<'a>

Creates an iterator from a value. Read more
source§

impl RefCast for RowRef

§

type From = [u8]

source§

fn ref_cast(_from: &Self::From) -> &Self

source§

fn ref_cast_mut(_from: &mut Self::From) -> &mut Self

Auto Trait Implementations§

§

impl RefUnwindSafe for RowRef

§

impl Send for RowRef

§

impl !Sized for RowRef

§

impl Sync for RowRef

§

impl Unpin for RowRef

§

impl UnwindSafe for RowRef

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more