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

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,

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>

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>

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>

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

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>

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>

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

§

fn deserialize(hex: &str) -> Value

§

impl ClaritySerializable for Value

§

fn serialize(&self) -> String

§

impl Clone for Value

§

fn clone(&self) -> Value

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Value

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for Value

§

fn deserialize<__D>( __deserializer: __D ) -> Result<Value, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl Display for Value

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl From<&Value> for TypePrefix

§

fn from(v: &Value) -> TypePrefix

Converts to this type from the input type.
§

impl From<ASCIIData> for Value

§

fn from(ascii: ASCIIData) -> Value

Converts to this type from the input type.
§

impl From<PrincipalData> for Value

§

fn from(p: PrincipalData) -> Value

Converts to this type from the input type.
§

impl From<QualifiedContractIdentifier> for Value

§

fn from(principal: QualifiedContractIdentifier) -> Value

Converts to this type from the input type.
§

impl From<StandardPrincipalData> for Value

§

fn from(principal: StandardPrincipalData) -> Value

Converts to this type from the input type.
§

impl From<TupleData> for Value

§

fn from(t: TupleData) -> Value

Converts to this type from the input type.
§

impl Hash for Value

§

fn hash<H>(&self, state: &mut H)where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl Into<Value> for ShortReturnType

§

fn into(self) -> Value

Converts this type into the (usually inferred) input type.
§

impl MemoryConsumer for Value

§

fn get_memory_use(&self) -> u64

§

impl PartialEq for Value

§

fn eq(&self, other: &Value) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

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

§

fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl StacksMessageCodec for Value

§

fn consensus_serialize<W>(&self, fd: &mut W) -> Result<(), Error>where W: Write,

serialize implementors should never error unless there is an underlying failure in writing to the fd
§

fn consensus_deserialize<R>(fd: &mut R) -> Result<Value, Error>where R: Read,

§

fn serialize_to_vec(&self) -> Vec<u8> where Self: Sized,

Convenience for serialization to a vec. this function unwraps any underlying serialization error
§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CallHasher for Twhere T: Hash + ?Sized,

§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64where H: Hash + ?Sized, B: BuildHasher,

§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,