Skip to main content

IdentifierLiteral

Struct IdentifierLiteral 

Source
pub struct IdentifierLiteral<E>
where E: Environment,
{ /* private fields */ }
Expand description

An identifier literal is an ASCII string (up to SIZE_IN_BYTES bytes) stored as a byte array.

The string content is stored as null-padded bytes in little-endian order.

Syntax: 'hello_world' (single-quoted, no type suffix). The allowed characters are: [a-zA-Z][a-zA-Z0-9_]*.

Implementations§

Source§

impl<E> IdentifierLiteral<E>
where E: Environment,

Source

pub fn new(string: &str) -> Result<IdentifierLiteral<E>, Error>

Creates a new identifier literal from a string. Allowed characters: [a-zA-Z][a-zA-Z0-9_]*.

Source

pub fn from_bytes_array(bytes: [u8; 31]) -> Result<IdentifierLiteral<E>, Error>

Creates an identifier literal from a byte array, validating the contents.

Source

pub fn bytes(&self) -> &[u8; 31]

Returns the bytes of the identifier literal.

Source

pub fn length(&self) -> u8

Returns the length of the identifier (number of non-null bytes).

Trait Implementations§

Source§

impl<N: Network> Cast<Address<N>> for IdentifierLiteral<N>

Source§

fn cast(&self) -> Result<Address<N>>

Casts an IdentifierLiteral to an Address.

Source§

impl<N: Network> Cast<Boolean<N>> for IdentifierLiteral<N>

Source§

fn cast(&self) -> Result<Boolean<N>>

Casts an IdentifierLiteral to a Boolean.

Note: This cast always fails because valid identifier literals start with a letter (first byte >= 0x41), which cannot represent a boolean field value (0 or 1). This implementation exists for uniformity with the impl_cast_body! macro used by all literal types.

Source§

impl<N: Network> Cast<Field<N>> for IdentifierLiteral<N>

Source§

fn cast(&self) -> Result<Field<N>>

Casts an IdentifierLiteral to a Field.

Source§

impl<N: Network> Cast<Group<N>> for IdentifierLiteral<N>

Source§

fn cast(&self) -> Result<Group<N>>

Casts an IdentifierLiteral to a Group.

Source§

impl<E: Environment> Cast<IdentifierLiteral<E>> for Boolean<E>

Source§

fn cast(&self) -> Result<IdentifierLiteral<E>>

Casts a Boolean to an IdentifierLiteral.

Note: This cast always fails because valid identifier literals cannot map to boolean values (0x00 or 0x01). The byte 0x00 is null and 0x01 (SOH) is not a valid identifier character. This implementation exists for uniformity with the impl_cast_body! macro used by all literal types.

Source§

impl<E: Environment> Cast<IdentifierLiteral<E>> for Field<E>

Source§

fn cast(&self) -> Result<IdentifierLiteral<E>>

Casts a Field to an IdentifierLiteral.

Source§

impl<E: Environment, I: IntegerType> Cast<IdentifierLiteral<E>> for Integer<E, I>

Source§

fn cast(&self) -> Result<IdentifierLiteral<E>>

Casts an Integer to an IdentifierLiteral.

Source§

impl<E: Environment> Cast<IdentifierLiteral<E>> for Scalar<E>

Source§

fn cast(&self) -> Result<IdentifierLiteral<E>>

Casts a Scalar to an IdentifierLiteral.

Source§

impl<N: Network, I: IntegerType> Cast<Integer<N, I>> for IdentifierLiteral<N>

Source§

fn cast(&self) -> Result<Integer<N, I>>

Casts an IdentifierLiteral to an Integer.

Source§

impl<N: Network> Cast<Scalar<N>> for IdentifierLiteral<N>

Source§

fn cast(&self) -> Result<Scalar<N>>

Casts an IdentifierLiteral to a Scalar.

Source§

impl<N: Network> Cast for IdentifierLiteral<N>

Source§

fn cast(&self) -> Result<IdentifierLiteral<N>>

Casts an IdentifierLiteral to itself.

Source§

impl<E> Clone for IdentifierLiteral<E>
where E: Clone + Environment,

Source§

fn clone(&self) -> IdentifierLiteral<E>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<E> Debug for IdentifierLiteral<E>
where E: Environment,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de, E> Deserialize<'de> for IdentifierLiteral<E>
where E: Environment,

Source§

fn deserialize<D>( deserializer: D, ) -> Result<IdentifierLiteral<E>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserializes the identifier literal from a string or bytes.

Source§

impl<E> Display for IdentifierLiteral<E>
where E: Environment,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<E> Distribution<IdentifierLiteral<E>> for Standard
where E: Environment,

Source§

fn sample<R>(&self, rng: &mut R) -> IdentifierLiteral<E>
where R: Rng + ?Sized,

Generate a random value of T, using rng as the source of randomness.
Source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
Source§

impl<E> Equal for IdentifierLiteral<E>
where E: Environment,

Source§

fn is_equal( &self, other: &IdentifierLiteral<E>, ) -> <IdentifierLiteral<E> as Equal>::Output

Returns true if self and other are equal.

Source§

fn is_not_equal( &self, other: &IdentifierLiteral<E>, ) -> <IdentifierLiteral<E> as Equal>::Output

Returns true if self and other are not equal.

Source§

type Output = Boolean<E>

Source§

impl<E> FromBits for IdentifierLiteral<E>
where E: Environment,

Source§

fn from_bits_le(bits_le: &[bool]) -> Result<IdentifierLiteral<E>, Error>

Initializes an identifier literal from a list of little-endian bits.

Source§

fn from_bits_be(bits_be: &[bool]) -> Result<IdentifierLiteral<E>, Error>

Initializes an identifier literal from a list of big-endian bits.

Source§

impl<E> FromBytes for IdentifierLiteral<E>
where E: Environment,

Source§

fn read_le<R>(reader: R) -> Result<IdentifierLiteral<E>, Error>
where R: Read,

Reads the identifier literal from a buffer.

Source§

fn from_bytes_le(bytes: &[u8]) -> Result<Self, Error>
where Self: Sized,

Returns Self from a byte array in little-endian order.
Source§

fn from_bytes_le_unchecked(bytes: &[u8]) -> Result<Self, Error>
where Self: Sized,

Same behavior as Self::from_bytes_le but avoids costly checks. This shall only be called when deserializing from a trusted source, such as local storage. Read more
Source§

fn read_le_unchecked<R>(reader: R) -> Result<Self, Error>
where R: Read, Self: Sized,

Same behavior as Self::read_le but avoids costly checks. This shall only be called when deserializing from a trusted source, such as local storage. Read more
Source§

fn read_le_with_unchecked<R>(reader: R, unchecked: bool) -> Result<Self, Error>
where R: Read, Self: Sized,

Helper function that deserializes either unchecked or checked based on the given boolean flag.
Source§

impl<E> FromField for IdentifierLiteral<E>
where E: Environment,

Source§

fn from_field( field: &<IdentifierLiteral<E> as FromField>::Field, ) -> Result<IdentifierLiteral<E>, Error>

Creates an identifier literal from a field element.

Source§

type Field = Field<E>

Source§

impl<E> FromStr for IdentifierLiteral<E>
where E: Environment,

Source§

fn from_str(string: &str) -> Result<IdentifierLiteral<E>, Error>

Parses a string into an identifier literal.

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

impl<E> Hash for IdentifierLiteral<E>
where E: Hash + Environment,

Source§

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
Source§

impl<E> Parser for IdentifierLiteral<E>
where E: Environment,

Source§

fn parse( string: &str, ) -> Result<(&str, IdentifierLiteral<E>), Err<VerboseError<&str>>>

Parses a string into an identifier literal. Syntax: '<identifier>' where identifier matches [a-zA-Z][a-zA-Z0-9_]*.

Source§

impl<E> PartialEq for IdentifierLiteral<E>

Source§

fn eq(&self, other: &IdentifierLiteral<E>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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

impl<E> Serialize for IdentifierLiteral<E>
where E: Environment,

Source§

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

Serializes the identifier literal into a string or bytes.

Source§

impl<E> SizeInBits for IdentifierLiteral<E>
where E: Environment,

Source§

fn size_in_bits() -> usize

Returns the size in bits of the identifier literal.

Source§

impl<E> SizeInBytes for IdentifierLiteral<E>
where E: Environment,

Source§

fn size_in_bytes() -> usize

Returns the size in bytes of the identifier literal.

Source§

impl<E> ToBits for IdentifierLiteral<E>
where E: Environment,

Source§

fn write_bits_le(&self, vec: &mut Vec<bool>)

Returns the little-endian bits of the identifier literal.

Source§

fn write_bits_be(&self, vec: &mut Vec<bool>)

Returns the big-endian bits of the identifier literal.

Source§

fn to_bits_le(&self) -> Vec<bool>

Returns self as a boolean array in little-endian order.
Source§

fn to_bits_be(&self) -> Vec<bool>

Returns self as a boolean array in big-endian order.
Source§

fn num_bits() -> Option<usize>

An optional indication of how many bits an object can be represented with.
Source§

impl<E> ToBytes for IdentifierLiteral<E>
where E: Environment,

Source§

fn write_le<W>(&self, writer: W) -> Result<(), Error>
where W: Write,

Writes the identifier literal to a buffer.

Source§

fn to_bytes_le(&self) -> Result<Vec<u8>, Error>
where Self: Sized,

Returns self as a byte array in little-endian order.
Source§

impl<E> ToField for IdentifierLiteral<E>
where E: Environment,

Source§

fn to_field(&self) -> Result<<IdentifierLiteral<E> as ToField>::Field, Error>

Returns the identifier literal as a field element.

Source§

type Field = Field<E>

Source§

impl<E> ToFields for IdentifierLiteral<E>
where E: Environment,

Source§

fn to_fields( &self, ) -> Result<Vec<<IdentifierLiteral<E> as ToFields>::Field>, Error>

Converts the identifier literal to a list of field elements.

Source§

type Field = Field<E>

Source§

impl<E> TypeName for IdentifierLiteral<E>
where E: Environment,

Source§

fn type_name() -> &'static str

Returns the type name as a string.

Source§

impl<E> Copy for IdentifierLiteral<E>
where E: Copy + Environment,

Source§

impl<E> Eq for IdentifierLiteral<E>
where E: Eq + Environment,

Source§

impl<E> StructuralPartialEq for IdentifierLiteral<E>
where E: Environment,

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<'de, T> DeserializeExt<'de> for T

Source§

fn take_from_value<D>( value: &mut Value, field: &str, ) -> Result<T, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Source§

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

Source§

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

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

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

Source§

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.

Source§

impl<T> Instrument for T

Source§

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

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

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 T
where 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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> ToSmolStr for T
where T: Display + ?Sized,

Source§

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

Source§

fn to_string(&self) -> String

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

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<T> Uniform for T

Source§

fn rand<R>(rng: &mut R) -> T
where R: Rng + ?Sized,

Samples a random value from a uniform distribution.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

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 T
where T: for<'de> Deserialize<'de>,