pub enum Ty {
Primitive(Primitive),
Struct(Struct),
Enum(Enum),
Tuple(Vec<Ty>),
Array(Vec<Ty>),
ByteArray(String),
FixedSizeArray((Vec<Ty>, u32)),
}Expand description
Represents all possible types in Cairo
Variants§
Primitive(Primitive)
Struct(Struct)
Enum(Enum)
Tuple(Vec<Ty>)
Array(Vec<Ty>)
ByteArray(String)
FixedSizeArray((Vec<Ty>, u32))
Implementations§
Source§impl Ty
impl Ty
pub fn name(&self) -> String
pub fn iter(&self) -> TyIter<'_> ⓘ
Sourcepub fn as_primitive(&self) -> Option<&Primitive>
pub fn as_primitive(&self) -> Option<&Primitive>
If the Ty is a primitive, returns the associated Primitive. Returns None
otherwise.
Sourcepub fn as_struct(&self) -> Option<&Struct>
pub fn as_struct(&self) -> Option<&Struct>
If the Ty is a struct, returns the associated Struct. Returns None otherwise.
Sourcepub fn as_enum(&self) -> Option<&Enum>
pub fn as_enum(&self) -> Option<&Enum>
If the Ty is an enum, returns the associated Enum. Returns None otherwise.
Sourcepub fn as_tuple(&self) -> Option<&Vec<Ty>>
pub fn as_tuple(&self) -> Option<&Vec<Ty>>
If the Ty is a tuple, returns the associated Vec<Ty>. Returns None otherwise.
Sourcepub fn as_array(&self) -> Option<&Vec<Ty>>
pub fn as_array(&self) -> Option<&Vec<Ty>>
If the Ty is an array, returns the associated Vec<Ty>. Returns None otherwise.
Sourcepub fn as_fixed_size_array(&self) -> Option<&(Vec<Ty>, u32)>
pub fn as_fixed_size_array(&self) -> Option<&(Vec<Ty>, u32)>
If the Ty is a fixed size array, returns the associated Vec<Ty>. Returns None
otherwise.
Sourcepub fn as_byte_array(&self) -> Option<&String>
pub fn as_byte_array(&self) -> Option<&String>
If the Ty is a byte array, returns the associated String. Returns None otherwise.
pub fn serialize(&self) -> Result<Vec<Felt>, PrimitiveError>
pub fn deserialize( &mut self, felts: &mut Vec<Felt>, legacy_storage: bool, ) -> Result<(), PrimitiveError>
Sourcepub fn diff(&self, other: &Ty) -> Option<Ty>
pub fn diff(&self, other: &Ty) -> Option<Ty>
Returns a new Ty containing only the differences between self and other
Sourcepub fn to_json_value(&self) -> Result<JsonValue, PrimitiveError>
pub fn to_json_value(&self) -> Result<JsonValue, PrimitiveError>
Convert a Ty to a JSON Value
Sourcepub fn from_json_value(
&mut self,
value: JsonValue,
) -> Result<(), PrimitiveError>
pub fn from_json_value( &mut self, value: JsonValue, ) -> Result<(), PrimitiveError>
Parse a JSON Value into a Ty
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Ty
impl<'de> Deserialize<'de> for Ty
Source§fn 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
impl Eq for Ty
impl StructuralPartialEq for Ty
Auto Trait Implementations§
impl Freeze for Ty
impl RefUnwindSafe for Ty
impl Send for Ty
impl Sync for Ty
impl Unpin for Ty
impl UnwindSafe for Ty
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> Casing<T> for T
impl<T> Casing<T> for T
Source§fn to_case(&self, case: Case<'_>) -> String
fn to_case(&self, case: Case<'_>) -> String
Convert the string into the given case. It will reference
self and create a new
String with the same pattern and delimeter as case. It will split on boundaries
defined at Boundary::defaults(). Read moreSource§fn with_boundaries(&self, bs: &[Boundary]) -> StateConverter<'_, T>
fn with_boundaries(&self, bs: &[Boundary]) -> StateConverter<'_, T>
Creates a
StateConverter struct initialized with the boundaries
provided. Read moreSource§fn without_boundaries(&self, bs: &[Boundary]) -> StateConverter<'_, T>
fn without_boundaries(&self, bs: &[Boundary]) -> StateConverter<'_, T>
Creates a
StateConverter struct initialized without the boundaries
provided. Read moreSource§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<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