pub enum Value {
Int(i128),
UInt(u128),
Bool(bool),
Sequence(SequenceData),
Principal(PrincipalData),
Tuple(TupleData),
Optional(OptionalData),
Response(ResponseData),
}
Variants
Int(i128)
UInt(u128)
Bool(bool)
Sequence(SequenceData)
Principal(PrincipalData)
Tuple(TupleData)
Optional(OptionalData)
Response(ResponseData)
Implementations
sourceimpl Value
impl Value
pub fn deserialize_read<R: Read>(
r: &mut R,
expected_type: Option<&TypeSignature>
) -> Result<Value, SerializationError>
pub fn serialize_write<W: Write>(&self, w: &mut W) -> Result<()>
sourcepub 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 hex string into a Clarity Value.
The expected_type
parameter determines whether or not the deserializer should 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.
If passed None
, the deserializer will construct the values as if they were literals in the contract, e.g.,
list max length = the length of the list.
pub fn try_deserialize_hex(
hex: &str,
expected: &TypeSignature
) -> Result<Value, SerializationError>
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) -> Self
sourceimpl Value
impl Value
pub fn some(data: Value) -> Result<Value>
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>
pub fn error(data: Value) -> Result<Value>
pub fn size(&self) -> u32
pub fn depth(&self) -> u8
sourcepub fn list_with_type(
list_data: Vec<Value>,
expected_type: ListTypeData
) -> Result<Value>
pub fn list_with_type(
list_data: Vec<Value>,
expected_type: ListTypeData
) -> Result<Value>
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>
pub fn buff_from(buff_data: Vec<u8>) -> Result<Value>
pub fn buff_from_byte(byte: u8) -> Value
pub fn string_ascii_from_bytes(bytes: Vec<u8>) -> Result<Value>
pub fn string_utf8_from_string_utf8_literal(
tokenized_str: String
) -> Result<Value>
pub fn string_utf8_from_bytes(bytes: Vec<u8>) -> Result<Value>
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>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn expect_list(self) -> Vec<Value>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn expect_buff_padded(self, sz: usize, pad: u8) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
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_result(self) -> Result<Value, Value>
pub fn expect_result_ok(self) -> Value
pub fn expect_result_err(self) -> Value
Trait Implementations
sourceimpl ClarityDeserializable<Value> for Value
impl ClarityDeserializable<Value> for Value
fn deserialize(hex: &str) -> Self
sourceimpl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl From<&'_ Value> for TypePrefix
impl From<&'_ Value> for TypePrefix
sourcefn from(v: &Value) -> TypePrefix
fn from(v: &Value) -> TypePrefix
Performs the conversion.
sourceimpl From<PrincipalData> for Value
impl From<PrincipalData> for Value
sourcefn from(p: PrincipalData) -> Self
fn from(p: PrincipalData) -> Self
Performs the conversion.
sourceimpl From<QualifiedContractIdentifier> for Value
impl From<QualifiedContractIdentifier> for Value
sourcefn from(principal: QualifiedContractIdentifier) -> Self
fn from(principal: QualifiedContractIdentifier) -> Self
Performs the conversion.
sourceimpl From<StandardPrincipalData> for Value
impl From<StandardPrincipalData> for Value
sourcefn from(principal: StandardPrincipalData) -> Self
fn from(principal: StandardPrincipalData) -> Self
Performs the conversion.
sourceimpl MemoryConsumer for Value
impl MemoryConsumer for Value
fn get_memory_use(&self) -> u64
sourceimpl SequencedValue<Value> for ListData
impl SequencedValue<Value> for ListData
fn items(&self) -> &Vec<Value>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
fn drained_items(&mut self) -> Vec<Value>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
fn type_signature(&self) -> TypeSignature
fn to_value(v: &Value) -> Value
fn atom_values(&mut self) -> Vec<SymbolicExpression>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
sourceimpl StacksMessageCodec for Value
impl StacksMessageCodec for Value
sourcefn consensus_serialize<W: Write>(&self, fd: &mut W) -> Result<(), CodecError>
fn consensus_serialize<W: Write>(&self, fd: &mut W) -> Result<(), CodecError>
serialize implementors should never error unless there is an underlying
failure in writing to the fd
Read more
fn consensus_deserialize<R: Read>(fd: &mut R) -> Result<Value, CodecError>
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcepub fn equivalent(&self, key: &K) -> bool
pub fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more