Struct casper_types::CLValue
source · pub struct CLValue { /* private fields */ }
Expand description
A Casper value, i.e. a value which can be stored and manipulated by smart contracts.
It holds the underlying data as a type-erased, serialized Vec<u8>
and also holds the
CLType
of the underlying data as a separate member.
Implementations§
source§impl CLValue
impl CLValue
sourcepub fn from_t<T: CLTyped + ToBytes>(t: T) -> Result<CLValue, CLValueError>
pub fn from_t<T: CLTyped + ToBytes>(t: T) -> Result<CLValue, CLValueError>
Constructs a CLValue
from t
.
sourcepub fn into_t<T: CLTyped + FromBytes>(self) -> Result<T, CLValueError>
pub fn into_t<T: CLTyped + FromBytes>(self) -> Result<T, CLValueError>
Consumes and converts self
back into its underlying type.
sourcepub fn inner_bytes(&self) -> &Vec<u8>
pub fn inner_bytes(&self) -> &Vec<u8>
Returns a reference to the serialized form of the underlying value held in this CLValue
.
sourcepub fn serialized_length(&self) -> usize
pub fn serialized_length(&self) -> usize
Returns the length of the Vec<u8>
yielded after calling self.to_bytes()
.
Note, this method doesn’t actually serialize self
, and hence is relatively cheap.
Trait Implementations§
source§impl<'de> Deserialize<'de> for CLValue
impl<'de> Deserialize<'de> for CLValue
source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
source§impl From<CLValue> for StoredValue
impl From<CLValue> for StoredValue
source§fn from(value: CLValue) -> StoredValue
fn from(value: CLValue) -> StoredValue
Converts to this type from the input type.
source§impl Ord for CLValue
impl Ord for CLValue
source§impl PartialEq for CLValue
impl PartialEq for CLValue
source§impl PartialOrd for CLValue
impl PartialOrd for CLValue
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl ToBytes for CLValue
impl ToBytes for CLValue
source§fn serialized_length(&self) -> usize
fn serialized_length(&self) -> usize
Returns the length of the
Vec<u8>
which would be returned from a successful call to
to_bytes()
or into_bytes()
. The data is not actually serialized, so this call is
relatively cheap.source§impl TryFrom<StoredValue> for CLValue
impl TryFrom<StoredValue> for CLValue
§type Error = TypeMismatch
type Error = TypeMismatch
The type returned in the event of a conversion error.
impl Eq for CLValue
impl StructuralEq for CLValue
impl StructuralPartialEq for CLValue
Auto Trait Implementations§
impl RefUnwindSafe for CLValue
impl Send for CLValue
impl Sync for CLValue
impl Unpin for CLValue
impl UnwindSafe for CLValue
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
Mutably borrows from an owned value. Read more