pub struct RowRef<'a> { /* private fields */ }Expand description
A reference to a single row within a table.
§Safety
Having a r: RowRef is a proof that r.pointer() refers to a valid row.
This makes constructing a RowRef, i.e., RowRef::new, an unsafe operation.
Implementations§
Source§impl<'a> RowRef<'a>
impl<'a> RowRef<'a>
Sourcepub fn to_product_value(&self) -> ProductValue
pub fn to_product_value(&self) -> ProductValue
Extract a ProductValue from the table.
This is a potentially expensive operation,
as it must walk the table’s ProductTypeLayout
and heap-allocate various substructures of the ProductValue.
Sourcepub fn read_col<T: ReadColumn>(
self,
col: impl Into<ColId>,
) -> Result<T, TypeError>
pub fn read_col<T: ReadColumn>( self, col: impl Into<ColId>, ) -> Result<T, TypeError>
Check that the idxth column of the row type stored by self is compatible with T,
and read the value of that column from self.
Sourcepub unsafe fn project_unchecked(self, cols: &ColList) -> AlgebraicValue
pub unsafe fn project_unchecked(self, cols: &ColList) -> AlgebraicValue
Construct a projection of the row at self by extracting the cols.
If cols contains zero or more than one column, the values of the projected columns are wrapped in a ProductValue.
If cols is a single column, the value of that column is returned without wrapping in a ProductValue.
§Safety
colsmust not specify any column which is out-of-bounds for the row `self´.
Sourcepub fn project(
self,
cols: &ColList,
) -> Result<AlgebraicValue, InvalidFieldError>
pub fn project( self, cols: &ColList, ) -> Result<AlgebraicValue, InvalidFieldError>
Construct a projection of the row at self by extracting the cols.
Returns an error if cols specifies an index which is out-of-bounds for the row at self.
If cols contains zero or more than one column, the values of the projected columns are wrapped in a ProductValue.
If cols is a single column, the value of that column is returned without wrapping in a ProductValue.
Sourcepub fn pointer(&self) -> RowPointer
pub fn pointer(&self) -> RowPointer
Returns the raw row pointer for this row reference.
Sourcepub fn row_layout(&self) -> &RowTypeLayout
pub fn row_layout(&self) -> &RowTypeLayout
Return the layout of the row.
All rows within the same table will have the same layout.
Sourcepub fn page_and_offset(&self) -> (&Page, PageOffset)
pub fn page_and_offset(&self) -> (&Page, PageOffset)
Returns the page the row is in and the offset of the row within that page.
Sourcepub fn static_layout(&self) -> Option<&StaticLayout>
pub fn static_layout(&self) -> Option<&StaticLayout>
Returns the static layout for this row reference, if any.
Sourcepub fn read_via_bsatn<T>(
&self,
scratch: &mut Vec<u8>,
) -> Result<T, ReadViaBsatnError>where
T: DeserializeOwned,
pub fn read_via_bsatn<T>(
&self,
scratch: &mut Vec<u8>,
) -> Result<T, ReadViaBsatnError>where
T: DeserializeOwned,
Encode the row referred to by self into a Vec<u8> using BSATN and then deserialize it.
Trait Implementations§
Source§impl PartialEq<ProductValue> for RowRef<'_>
impl PartialEq<ProductValue> for RowRef<'_>
Source§impl ToBsatn for RowRef<'_>
impl ToBsatn for RowRef<'_>
Source§fn to_bsatn_vec(&self) -> Result<Vec<u8>, BsatnError>
fn to_bsatn_vec(&self) -> Result<Vec<u8>, BsatnError>
BSATN-encode the row referred to by self into a freshly-allocated Vec<u8>.
This method will use a StaticLayout if one is available,
and may therefore be faster than calling bsatn::to_vec.
Source§fn to_bsatn_extend(&self, buf: &mut Vec<u8>) -> Result<(), BsatnError>
fn to_bsatn_extend(&self, buf: &mut Vec<u8>) -> Result<(), BsatnError>
BSATN-encode the row referred to by self into buf,
pushing self’s bytes onto the end of buf, similar to Vec::extend.
This method will use a StaticLayout if one is available,
and may therefore be faster than calling bsatn::to_writer.
impl<'a> Copy for RowRef<'a>
impl Eq for RowRef<'_>
Auto Trait Implementations§
impl<'a> Freeze for RowRef<'a>
impl<'a> !RefUnwindSafe for RowRef<'a>
impl<'a> Send for RowRef<'a>
impl<'a> Sync for RowRef<'a>
impl<'a> Unpin for RowRef<'a>
impl<'a> !UnwindSafe for RowRef<'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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> Satn for T
impl<T> Satn for T
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
f.Source§fn fmt_psql(&self, f: &mut Formatter<'_>, ty: &ProductType) -> Result<(), Error>
fn fmt_psql(&self, f: &mut Formatter<'_>, ty: &ProductType) -> Result<(), Error>
f.Source§fn to_satn(&self) -> String
fn to_satn(&self) -> String
String.Source§fn to_satn_pretty(&self) -> String
fn to_satn_pretty(&self) -> String
String.