Struct spacetimedb_lib::ProductValue
source · pub struct ProductValue {
pub elements: Vec<AlgebraicValue, Global>,
}Expand description
A product value is made of a a list of
“elements” / “fields” / “factors” of other AlgebraicValues.
The type of a product value is a product type.
Fields§
§elements: Vec<AlgebraicValue, Global>The values that make up this product value.
Implementations§
source§impl ProductValue
impl ProductValue
pub fn decode<'a>( algebraic_type: &<ProductValue as Value>::Type, bytes: &mut impl BufReader<'a> ) -> Result<ProductValue, DecodeError>
pub fn encode(&self, bytes: &mut impl BufWriter)
source§impl ProductValue
impl ProductValue
sourcepub fn new(elements: &[AlgebraicValue]) -> ProductValue
pub fn new(elements: &[AlgebraicValue]) -> ProductValue
Returns a product value constructed from the given values in elements.
source§impl ProductValue
impl ProductValue
sourcepub fn get_field(
&self,
index: usize,
name: Option<&'static str>
) -> Result<&AlgebraicValue, InvalidFieldError>
pub fn get_field( &self, index: usize, name: Option<&'static str> ) -> Result<&AlgebraicValue, InvalidFieldError>
Borrow the value at field of self indentified by index.
The name is non-functional and is only used for error-messages.
sourcepub fn extract_field<'a, T>(
&'a self,
index: usize,
name: Option<&'static str>,
f: impl Fn(&'a AlgebraicValue) -> Option<T> + 'a
) -> Result<T, InvalidFieldError>
pub fn extract_field<'a, T>( &'a self, index: usize, name: Option<&'static str>, f: impl Fn(&'a AlgebraicValue) -> Option<T> + 'a ) -> 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 indentified 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 indentified 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 indentified by index as a u32.
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 indentified 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 indentified 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 indentified 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 indentified 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 indentified by index as a byte slice.
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 From<&AlgebraicValue> for ProductValue
impl From<&AlgebraicValue> for ProductValue
source§fn from(x: &AlgebraicValue) -> ProductValue
fn from(x: &AlgebraicValue) -> ProductValue
source§impl From<AlgebraicValue> for ProductValue
impl From<AlgebraicValue> for ProductValue
source§fn from(x: AlgebraicValue) -> ProductValue
fn from(x: AlgebraicValue) -> ProductValue
source§impl From<ProductValue> for AlgebraicValue
impl From<ProductValue> for AlgebraicValue
source§fn from(x: ProductValue) -> AlgebraicValue
fn from(x: ProductValue) -> AlgebraicValue
source§impl FromIterator<AlgebraicValue> for ProductValue
impl FromIterator<AlgebraicValue> for ProductValue
source§fn from_iter<T>(iter: T) -> ProductValuewhere
T: IntoIterator<Item = AlgebraicValue>,
fn from_iter<T>(iter: T) -> ProductValuewhere T: IntoIterator<Item = AlgebraicValue>,
source§impl Hash for ProductValue
impl Hash 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<ProductValue> for ProductValue
impl PartialEq<ProductValue> 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<ProductValue> for ProductValue
impl PartialOrd<ProductValue> 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§fn serialize<S>(
&self,
ser: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>( &self, ser: S ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where S: Serializer,
self in the data format of S using the provided serializer.source§impl Serialize for ProductValue
impl Serialize for ProductValue
source§fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>( &self, serializer: S ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where S: Serializer,
source§impl ToDataKey for ProductValue
impl ToDataKey for ProductValue
fn to_data_key(&self) -> DataKey
source§impl Value for ProductValue
impl Value for ProductValue
§type Type = ProductType
type Type = ProductType
impl Eq for ProductValue
impl StructuralEq for ProductValue
impl StructuralPartialEq for ProductValue
Auto Trait Implementations§
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<T> Satn for Twhere
T: Serialize + ?Sized,
impl<T> Satn for Twhere T: Serialize + ?Sized,
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<'_>) -> Result<(), Error>
fn fmt_psql(&self, f: &mut Formatter<'_>) -> 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.