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 to_t<T: CLTyped + FromBytes>(&self) -> Result<T, CLValueError>
pub fn to_t<T: CLTyped + FromBytes>(&self) -> Result<T, CLValueError>
Converts self
into its underlying type.
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 DataSize for CLValue
impl DataSize for CLValue
Source§const IS_DYNAMIC: bool = true
const IS_DYNAMIC: bool = true
If
true
, the type has a heap size that can vary at runtime, depending on the actual value.Source§const STATIC_HEAP_SIZE: usize = 0usize
const STATIC_HEAP_SIZE: usize = 0usize
The amount of space a value of the type always occupies. If
IS_DYNAMIC
is false, this is
the total amount of heap memory occupied by the value. Otherwise this is a lower bound.Source§fn estimate_heap_size(&self) -> usize
fn estimate_heap_size(&self) -> usize
Estimates the size of heap memory taken up by this value. Read more
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 JsonSchema for CLValue
Available on crate feature json-schema
only.We need to implement JsonSchema
for CLValue
as though it is a CLValueJson
.
impl JsonSchema for CLValue
Available on crate feature
json-schema
only.We need to implement JsonSchema
for CLValue
as though it is a CLValueJson
.
Source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read moreSource§impl Ord for CLValue
impl Ord for CLValue
Source§impl PartialOrd for CLValue
impl PartialOrd for CLValue
Source§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
Source§type Error = TypeMismatch
type Error = TypeMismatch
The type returned in the event of a conversion error.
impl Eq for CLValue
impl StructuralPartialEq for CLValue
Auto Trait Implementations§
impl Freeze for CLValue
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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
Compare self to
key
and return true
if they are equal.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
Compare self to
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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 more