Enum stacks_rpc_client::clarity::vm::Value
pub enum Value {
Int(i128),
UInt(u128),
Bool(bool),
Sequence(SequenceData),
Principal(PrincipalData),
Tuple(TupleData),
Optional(OptionalData),
Response(ResponseData),
CallableContract(CallableData),
}
Variants§
Int(i128)
UInt(u128)
Bool(bool)
Sequence(SequenceData)
Principal(PrincipalData)
Tuple(TupleData)
Optional(OptionalData)
Response(ResponseData)
CallableContract(CallableData)
Implementations§
§impl Value
impl Value
pub fn deserialize_read<R>( r: &mut R, expected_type: Option<&TypeSignature> ) -> Result<Value, SerializationError>where R: Read,
pub fn deserialize_read_count<R>(
r: &mut R,
expected_type: Option<&TypeSignature>
) -> Result<(Value, u64), SerializationError>where
R: Read,
pub fn deserialize_read_count<R>( r: &mut R, expected_type: Option<&TypeSignature> ) -> Result<(Value, u64), SerializationError>where R: Read,
Deserialize just like deserialize_read
but also
return the bytes read
pub fn serialize_write<W>(&self, w: &mut W) -> Result<(), Error>where W: Write,
pub fn try_deserialize_bytes(
bytes: &Vec<u8>,
expected: &TypeSignature
) -> Result<Value, SerializationError>
pub fn try_deserialize_bytes( bytes: &Vec<u8>, expected: &TypeSignature ) -> Result<Value, SerializationError>
This function attempts to deserialize a byte buffer into a Clarity Value.
The expected_type
parameter tells the deserializer to expect (and enforce)
a particular type. ClarityDB
uses this to ensure that lists, tuples, etc. loaded from the database
have their max-length and other type information set by the type declarations in the contract.
pub fn try_deserialize_hex(
hex: &str,
expected: &TypeSignature
) -> Result<Value, SerializationError>
pub fn try_deserialize_hex( hex: &str, expected: &TypeSignature ) -> Result<Value, SerializationError>
This function attempts to deserialize a hex string into a Clarity Value.
The expected_type
parameter tells the deserializer to expect (and enforce)
a particular type. ClarityDB
uses this to ensure that lists, tuples, etc. loaded from the database
have their max-length and other type information set by the type declarations in the contract.
pub fn try_deserialize_bytes_exact(
bytes: &Vec<u8>,
expected: &TypeSignature
) -> Result<Value, SerializationError>
pub fn try_deserialize_bytes_exact( bytes: &Vec<u8>, expected: &TypeSignature ) -> Result<Value, SerializationError>
This function attempts to deserialize a byte buffer into a
Clarity Value, while ensuring that the whole byte buffer is
consumed by the deserialization, erroring if it is not. The
expected_type
parameter tells the deserializer to expect
(and enforce) a particular type. ClarityDB
uses this to
ensure that lists, tuples, etc. loaded from the database have
their max-length and other type information set by the type
declarations in the contract.
pub fn try_deserialize_bytes_untyped( bytes: &Vec<u8> ) -> Result<Value, SerializationError>
pub fn try_deserialize_hex_untyped( hex: &str ) -> Result<Value, SerializationError>
pub fn deserialize(hex: &str, expected: &TypeSignature) -> Value
pub fn serialized_size(&self) -> u32
§impl Value
impl Value
pub fn some(data: Value) -> Result<Value, Error>
pub fn none() -> Value
pub fn okay_true() -> Value
pub fn err_uint(ecode: u128) -> Value
pub fn err_none() -> Value
pub fn okay(data: Value) -> Result<Value, Error>
pub fn error(data: Value) -> Result<Value, Error>
pub fn size(&self) -> u32
pub fn depth(&self) -> u8
pub fn list_with_type(
epoch: &StacksEpochId,
list_data: Vec<Value>,
expected_type: ListTypeData
) -> Result<Value, Error>
pub fn list_with_type( epoch: &StacksEpochId, list_data: Vec<Value>, expected_type: ListTypeData ) -> Result<Value, Error>
Invariant: the supplied Values have already been “checked”, i.e., it’s a valid Value object this invariant is enforced through the Value constructors, each of which checks to ensure that any typing data is correct.
pub fn list_from(list_data: Vec<Value>) -> Result<Value, Error>
pub fn buff_from(buff_data: Vec<u8>) -> Result<Value, Error>
pub fn buff_from(buff_data: Vec<u8>) -> Result<Value, Error>
Errors
- CheckErrors::ValueTooLarge if
buff_data
is too large.
pub fn buff_from_byte(byte: u8) -> Value
pub fn string_ascii_from_bytes(bytes: Vec<u8>) -> Result<Value, Error>
pub fn string_utf8_from_string_utf8_literal( tokenized_str: String ) -> Result<Value, Error>
pub fn string_utf8_from_bytes(bytes: Vec<u8>) -> Result<Value, Error>
pub fn expect_ascii(self) -> String
pub fn expect_u128(self) -> u128
pub fn expect_i128(self) -> i128
pub fn expect_buff(self, sz: usize) -> Vec<u8> ⓘ
pub fn expect_list(self) -> Vec<Value>
pub fn expect_buff_padded(self, sz: usize, pad: u8) -> Vec<u8> ⓘ
pub fn expect_bool(self) -> bool
pub fn expect_tuple(self) -> TupleData
pub fn expect_optional(self) -> Option<Value>
pub fn expect_principal(self) -> PrincipalData
pub fn expect_callable(self) -> CallableData
pub fn expect_result(self) -> Result<Value, Value>
pub fn expect_result_ok(self) -> Value
pub fn expect_result_err(self) -> Value
Trait Implementations§
§impl ClarityDeserializable<Value> for Value
impl ClarityDeserializable<Value> for Value
fn deserialize(hex: &str) -> Value
§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
§fn deserialize<__D>(
__deserializer: __D
) -> Result<Value, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>( __deserializer: __D ) -> Result<Value, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,
§impl From<&Value> for TypePrefix
impl From<&Value> for TypePrefix
§fn from(v: &Value) -> TypePrefix
fn from(v: &Value) -> TypePrefix
§impl From<PrincipalData> for Value
impl From<PrincipalData> for Value
§fn from(p: PrincipalData) -> Value
fn from(p: PrincipalData) -> Value
§impl From<QualifiedContractIdentifier> for Value
impl From<QualifiedContractIdentifier> for Value
§fn from(principal: QualifiedContractIdentifier) -> Value
fn from(principal: QualifiedContractIdentifier) -> Value
§impl From<StandardPrincipalData> for Value
impl From<StandardPrincipalData> for Value
§fn from(principal: StandardPrincipalData) -> Value
fn from(principal: StandardPrincipalData) -> Value
§impl Into<Value> for ShortReturnType
impl Into<Value> for ShortReturnType
§impl MemoryConsumer for Value
impl MemoryConsumer for Value
fn get_memory_use(&self) -> u64
§impl SequencedValue<Value> for ListData
impl SequencedValue<Value> for ListData
fn items(&self) -> &Vec<Value>
fn drained_items(&mut self) -> Vec<Value>
fn type_signature(&self) -> TypeSignature
fn to_value(v: &Value) -> Value
fn atom_values(&mut self) -> Vec<SymbolicExpression>
§impl Serialize for Value
impl Serialize for Value
§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,
§impl StacksMessageCodec for Value
impl StacksMessageCodec for Value
impl Eq for Value
impl StructuralEq for Value
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.