Enum clarity_repl::clarity::types::signatures::TypeSignature
source · [−]pub enum TypeSignature {
NoType,
IntType,
UIntType,
BoolType,
SequenceType(SequenceSubtype),
PrincipalType,
TupleType(TupleTypeSignature),
OptionalType(Box<TypeSignature>),
ResponseType(Box<(TypeSignature, TypeSignature)>),
TraitReferenceType(TraitIdentifier),
}
Variants
NoType
IntType
UIntType
BoolType
SequenceType(SequenceSubtype)
PrincipalType
TupleType(TupleTypeSignature)
OptionalType(Box<TypeSignature>)
ResponseType(Box<(TypeSignature, TypeSignature)>)
TraitReferenceType(TraitIdentifier)
Implementations
sourceimpl TypeSignature
impl TypeSignature
pub fn new_option(
inner_type: TypeSignature
) -> Result<TypeSignature, CheckErrors>
pub fn new_response(
ok_type: TypeSignature,
err_type: TypeSignature
) -> Result<TypeSignature, CheckErrors>
pub fn is_response_type(&self) -> bool
pub fn is_no_type(&self) -> bool
pub fn admits(&self, x: &Value) -> bool
pub fn admits_type(&self, other: &TypeSignature) -> bool
sourceimpl TypeSignature
impl TypeSignature
pub fn empty_buffer() -> TypeSignature
pub fn min_buffer() -> TypeSignature
pub fn min_string_ascii() -> TypeSignature
pub fn min_string_utf8() -> TypeSignature
pub fn max_buffer() -> TypeSignature
sourcepub fn factor_out_no_type(
a: &TypeSignature,
b: &TypeSignature
) -> Result<TypeSignature, CheckErrors>
pub fn factor_out_no_type(
a: &TypeSignature,
b: &TypeSignature
) -> Result<TypeSignature, CheckErrors>
If one of the types is a NoType, return Ok(the other type), otherwise return least_supertype(a, b)
sourcepub fn least_supertype(
a: &TypeSignature,
b: &TypeSignature
) -> Result<TypeSignature, CheckErrors>
pub fn least_supertype(
a: &TypeSignature,
b: &TypeSignature
) -> Result<TypeSignature, CheckErrors>
This function returns the most-restrictive type that admits both A and B (something like a least common supertype), or Errors if no such type exists. On error, it throws NoSuperType(A,B), unless a constructor error’ed – in which case, it throws the constructor’s error.
For two Tuples: least_supertype(A, B) := (tuple \for_each(key k) least_supertype(type_a_k, type_b_k)) For two Lists: least_supertype(A, B) := (list max_len: max(max_len A, max_len B), entry: least_supertype(entry_a, entry_b)) if max_len A | max_len B is 0: entry := Non-empty list entry For two responses: least_supertype(A, B) := (response least_supertype(ok_a, ok_b), least_supertype(err_a, err_b)) if any entries are NoType, use the other type’s entry For two options: least_supertype(A, B) := (option least_supertype(some_a, some_b)) if some_a | some_b is NoType, use the other type’s entry. For buffers: least_supertype(A, B) := (buff len: max(len A, len B)) For ints, uints, principals, bools: least_supertype(A, B) := if A != B, error, else A
pub fn list_of(
item_type: TypeSignature,
max_len: u32
) -> Result<TypeSignature, CheckErrors>
pub fn empty_list() -> ListTypeData
pub fn type_of(x: &Value) -> TypeSignature
pub fn construct_parent_list_type(
args: &[Value]
) -> Result<ListTypeData, CheckErrors>
pub fn parent_list_type(
children: &[TypeSignature]
) -> Result<ListTypeData, CheckErrors>
sourceimpl TypeSignature
impl TypeSignature
Parsing functions.
pub fn parse_response_type_repr<A: CostTracker>(
type_args: &[SymbolicExpression],
accounting: &mut A
) -> Result<TypeSignature, CheckErrors>
pub fn parse_type_repr<A: CostTracker>(
x: &SymbolicExpression,
accounting: &mut A
) -> Result<TypeSignature, CheckErrors>
pub fn parse_trait_type_repr<A: CostTracker>(
type_args: &[SymbolicExpression],
accounting: &mut A
) -> Result<BTreeMap<ClarityName, FunctionSignature>, CheckErrors>
sourceimpl TypeSignature
impl TypeSignature
These implement the size calculations in TypeSignatures
in constructors of TypeSignatures, only .inner_size()
may be called.
.inner_size is a failable method to compute the size of the type signature,
Failures indicate that a type signature represents too large of a value.
TypeSignature constructors will fail instead of constructing such a type.
because of this, the public interface to size is infallible.
Trait Implementations
sourceimpl Clone for TypeSignature
impl Clone for TypeSignature
sourcefn clone(&self) -> TypeSignature
fn clone(&self) -> TypeSignature
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for TypeSignature
impl Debug for TypeSignature
sourceimpl<'de> Deserialize<'de> for TypeSignature
impl<'de> Deserialize<'de> for TypeSignature
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 Display for TypeSignature
impl Display for TypeSignature
sourceimpl From<ListTypeData> for TypeSignature
impl From<ListTypeData> for TypeSignature
sourcefn from(data: ListTypeData) -> Self
fn from(data: ListTypeData) -> Self
Performs the conversion.
sourceimpl From<TupleTypeSignature> for TypeSignature
impl From<TupleTypeSignature> for TypeSignature
sourcefn from(data: TupleTypeSignature) -> Self
fn from(data: TupleTypeSignature) -> Self
Performs the conversion.
sourceimpl PartialEq<TypeSignature> for TypeSignature
impl PartialEq<TypeSignature> for TypeSignature
sourcefn eq(&self, other: &TypeSignature) -> bool
fn eq(&self, other: &TypeSignature) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &TypeSignature) -> bool
fn ne(&self, other: &TypeSignature) -> bool
This method tests for !=
.
sourceimpl Serialize for TypeSignature
impl Serialize for TypeSignature
impl Eq for TypeSignature
impl StructuralEq for TypeSignature
impl StructuralPartialEq for TypeSignature
Auto Trait Implementations
impl RefUnwindSafe for TypeSignature
impl Send for TypeSignature
impl Sync for TypeSignature
impl Unpin for TypeSignature
impl UnwindSafe for TypeSignature
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