Struct spacetimedb_sats::product_value::ProductValue
source · pub struct ProductValue {
pub elements: Box<[AlgebraicValue]>,
}
Expand description
A product value is made of a list of
“elements” / “fields” / “factors” of other AlgebraicValue
s.
The type of a product value is a product type.
Fields§
§elements: Box<[AlgebraicValue]>
The values that make up this product value.
Implementations§
source§impl ProductValue
impl ProductValue
sourcepub fn decode<'a>(
ty: &<Self as Value>::Type,
bytes: &mut impl BufReader<'a>,
) -> Result<Self, DecodeError>
pub fn decode<'a>( ty: &<Self as Value>::Type, bytes: &mut impl BufReader<'a>, ) -> Result<Self, DecodeError>
Decode a value from bytes
typed at ty
.
sourcepub fn decode_smallvec<'a>(
ty: &<Self as Value>::Type,
bytes: &mut impl BufReader<'a>,
) -> Result<SmallVec<[Self; 1]>, DecodeError>
pub fn decode_smallvec<'a>( ty: &<Self as Value>::Type, bytes: &mut impl BufReader<'a>, ) -> Result<SmallVec<[Self; 1]>, DecodeError>
Decode a vector of values from bytes
with each value typed at ty
.
pub fn encode(&self, bytes: &mut impl BufWriter)
source§impl ProductValue
impl ProductValue
sourcepub fn get_field(
&self,
col_pos: usize,
name: Option<&'static str>,
) -> Result<&AlgebraicValue, InvalidFieldError>
pub fn get_field( &self, col_pos: usize, name: Option<&'static str>, ) -> Result<&AlgebraicValue, InvalidFieldError>
Borrow the value at field of self
identified by col_pos
.
The name
is non-functional and is only used for error-messages.
sourcepub fn project(
&self,
indexes: &[(ColId, Option<&'static str>)],
) -> Result<AlgebraicValue, InvalidFieldError>
pub fn project( &self, indexes: &[(ColId, Option<&'static str>)], ) -> Result<AlgebraicValue, InvalidFieldError>
This function is used to project fields based on the provided indexes
.
It will raise an InvalidFieldError if any of the supplied indexes
cannot be found.
The optional parameter name: Option<&'static str>
serves a non-functional role and is
solely utilized for generating error messages.
Important:
The resulting AlgebraicValue will wrap into a ProductValue when projecting multiple fields, otherwise it will consist of a single AlgebraicValue.
sourcepub fn project_not_empty(
&self,
cols: &ColList,
) -> Result<AlgebraicValue, InvalidFieldError>
pub fn project_not_empty( &self, cols: &ColList, ) -> Result<AlgebraicValue, InvalidFieldError>
This utility function is designed to project fields based on the supplied indexes
.
Important:
The resulting AlgebraicValue will wrap into a ProductValue when projecting multiple fields, otherwise it will consist of a single AlgebraicValue.
Parameters:
cols
: A ColList containing the indexes of fields to be projected.s
sourcepub fn extract_field<'a, T>(
&'a self,
col_pos: usize,
name: Option<&'static str>,
f: impl 'a + Fn(&'a AlgebraicValue) -> Option<T>,
) -> Result<T, InvalidFieldError>
pub fn extract_field<'a, T>( &'a self, col_pos: usize, name: Option<&'static str>, f: impl 'a + Fn(&'a AlgebraicValue) -> Option<T>, ) -> Result<T, InvalidFieldError>
Extracts the value
at field of self
identified by index
and then runs it through the function f
which possibly returns a T
derived from value
.
sourcepub fn field_as_bool(
&self,
index: usize,
named: Option<&'static str>,
) -> Result<bool, InvalidFieldError>
pub fn field_as_bool( &self, index: usize, named: Option<&'static str>, ) -> Result<bool, InvalidFieldError>
Interprets the value at field of self
identified by index
as a bool
.
sourcepub fn field_as_u8(
&self,
index: usize,
named: Option<&'static str>,
) -> Result<u8, InvalidFieldError>
pub fn field_as_u8( &self, index: usize, named: Option<&'static str>, ) -> Result<u8, InvalidFieldError>
Interprets the value at field of self
identified by index
as a u8
.
sourcepub fn field_as_u32(
&self,
index: usize,
named: Option<&'static str>,
) -> Result<u32, InvalidFieldError>
pub fn field_as_u32( &self, index: usize, named: Option<&'static str>, ) -> Result<u32, InvalidFieldError>
Interprets the value at field of self
identified by index
as a u32
.
sourcepub fn field_as_u64(
&self,
index: usize,
named: Option<&'static str>,
) -> Result<u64, InvalidFieldError>
pub fn field_as_u64( &self, index: usize, named: Option<&'static str>, ) -> Result<u64, InvalidFieldError>
Interprets the value at field of self
identified by index
as a u64
.
sourcepub fn field_as_i64(
&self,
index: usize,
named: Option<&'static str>,
) -> Result<i64, InvalidFieldError>
pub fn field_as_i64( &self, index: usize, named: Option<&'static str>, ) -> Result<i64, InvalidFieldError>
Interprets the value at field of self
identified by index
as a i64
.
sourcepub fn field_as_i128(
&self,
index: usize,
named: Option<&'static str>,
) -> Result<i128, InvalidFieldError>
pub fn field_as_i128( &self, index: usize, named: Option<&'static str>, ) -> Result<i128, InvalidFieldError>
Interprets the value at field of self
identified by index
as a i128
.
sourcepub fn field_as_u128(
&self,
index: usize,
named: Option<&'static str>,
) -> Result<u128, InvalidFieldError>
pub fn field_as_u128( &self, index: usize, named: Option<&'static str>, ) -> Result<u128, InvalidFieldError>
Interprets the value at field of self
identified by index
as a u128
.
sourcepub fn field_as_str(
&self,
index: usize,
named: Option<&'static str>,
) -> Result<&str, InvalidFieldError>
pub fn field_as_str( &self, index: usize, named: Option<&'static str>, ) -> Result<&str, InvalidFieldError>
Interprets the value at field of self
identified by index
as a string slice.
sourcepub fn field_as_bytes(
&self,
index: usize,
named: Option<&'static str>,
) -> Result<&[u8], InvalidFieldError>
pub fn field_as_bytes( &self, index: usize, named: Option<&'static str>, ) -> Result<&[u8], InvalidFieldError>
Interprets the value at field of self
identified by index
as a byte slice.
sourcepub fn field_as_array(
&self,
index: usize,
named: Option<&'static str>,
) -> Result<&ArrayValue, InvalidFieldError>
pub fn field_as_array( &self, index: usize, named: Option<&'static str>, ) -> Result<&ArrayValue, InvalidFieldError>
Interprets the value at field of self
identified by index
as an ArrayValue
.
sourcepub fn field_as_sum(
&self,
index: usize,
named: Option<&'static str>,
) -> Result<SumValue, InvalidFieldError>
pub fn field_as_sum( &self, index: usize, named: Option<&'static str>, ) -> Result<SumValue, InvalidFieldError>
Interprets the value at field of self
identified by index
as a SumValue
.
Trait Implementations§
source§impl Clone for ProductValue
impl Clone for ProductValue
source§fn clone(&self) -> ProductValue
fn clone(&self) -> ProductValue
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ProductValue
impl Debug for ProductValue
source§impl Default for ProductValue
impl Default for ProductValue
source§fn default() -> ProductValue
fn default() -> ProductValue
source§impl From<AlgebraicValue> for ProductValue
impl From<AlgebraicValue> for ProductValue
source§fn from(x: AlgebraicValue) -> Self
fn from(x: AlgebraicValue) -> Self
source§impl From<ProductValue> for AlgebraicValue
impl From<ProductValue> for AlgebraicValue
source§fn from(original: ProductValue) -> AlgebraicValue
fn from(original: ProductValue) -> AlgebraicValue
source§impl<X: Into<Box<[AlgebraicValue]>>> From<X> for ProductValue
impl<X: Into<Box<[AlgebraicValue]>>> From<X> for ProductValue
source§impl FromIterator<AlgebraicValue> for ProductValue
impl FromIterator<AlgebraicValue> for ProductValue
source§fn from_iter<T: IntoIterator<Item = AlgebraicValue>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = AlgebraicValue>>(iter: T) -> Self
source§impl Hash for ProductValue
impl Hash for ProductValue
The hash function for ProductValue
does not length prefix.
source§impl<'a> IntoIterator for &'a ProductValue
impl<'a> IntoIterator for &'a ProductValue
source§impl IntoIterator for ProductValue
impl IntoIterator for ProductValue
source§impl Ord for ProductValue
impl Ord for ProductValue
source§fn cmp(&self, other: &ProductValue) -> Ordering
fn cmp(&self, other: &ProductValue) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for ProductValue
impl PartialEq for ProductValue
source§fn eq(&self, other: &ProductValue) -> bool
fn eq(&self, other: &ProductValue) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for ProductValue
impl PartialOrd for ProductValue
source§fn partial_cmp(&self, other: &ProductValue) -> Option<Ordering>
fn partial_cmp(&self, other: &ProductValue) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for ProductValue
impl Serialize for ProductValue
source§impl Value for ProductValue
impl Value for ProductValue
§type Type = ProductType
type Type = ProductType
impl Eq for ProductValue
impl StructuralPartialEq for ProductValue
Auto Trait Implementations§
impl Freeze for ProductValue
impl RefUnwindSafe for ProductValue
impl Send for ProductValue
impl Sync for ProductValue
impl Unpin for ProductValue
impl UnwindSafe for ProductValue
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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
fn fmt(&self, f: &mut Formatter<'_>) -> Result
f
.source§fn fmt_psql(&self, f: &mut Formatter<'_>, ty: &ProductType) -> Result
fn fmt_psql(&self, f: &mut Formatter<'_>, ty: &ProductType) -> Result
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
.