pub struct RuntimeArgs(/* private fields */);
Expand description
Represents a collection of arguments passed to a smart contract.
Implementations§
Source§impl RuntimeArgs
impl RuntimeArgs
Sourcepub fn new() -> RuntimeArgs
pub fn new() -> RuntimeArgs
Create an empty RuntimeArgs
instance.
Sourcepub fn try_new<F>(func: F) -> Result<RuntimeArgs, CLValueError>
pub fn try_new<F>(func: F) -> Result<RuntimeArgs, CLValueError>
A wrapper that lets you easily and safely create runtime arguments.
This method is useful when you have to construct a RuntimeArgs
with multiple entries,
but error handling at given call site would require to have a match statement for each
RuntimeArgs::insert
call. With this method you can use ? operator inside the closure and
then handle single result. When try_block
will be stabilized this method could be
deprecated in favor of using those blocks.
Sourcepub fn insert<K, V>(&mut self, key: K, value: V) -> Result<(), CLValueError>
pub fn insert<K, V>(&mut self, key: K, value: V) -> Result<(), CLValueError>
Inserts a new named argument into the collection.
Sourcepub fn insert_cl_value<K>(&mut self, key: K, cl_value: CLValue)
pub fn insert_cl_value<K>(&mut self, key: K, cl_value: CLValue)
Inserts a new named argument into the collection.
Sourcepub fn named_args(&self) -> impl Iterator<Item = &NamedArg>
pub fn named_args(&self) -> impl Iterator<Item = &NamedArg>
Returns an iterator of references over all arguments in insertion order.
Sourcepub fn named_args_mut(&mut self) -> impl Iterator<Item = &mut NamedArg>
pub fn named_args_mut(&mut self) -> impl Iterator<Item = &mut NamedArg>
Returns an iterator of mutable references over all arguments in insertion order.
Sourcepub fn try_get_number(&self, name: &str) -> Result<U512, CLValueError>
pub fn try_get_number(&self, name: &str) -> Result<U512, CLValueError>
Returns the numeric value of name
arg from the runtime arguments or defaults to
0 if that arg doesn’t exist or is not an integer type.
Supported CLType
s for numeric conversions are U64, and U512.
Returns an error if parsing the arg fails.
Trait Implementations§
Source§impl Clone for RuntimeArgs
impl Clone for RuntimeArgs
Source§fn clone(&self) -> RuntimeArgs
fn clone(&self) -> RuntimeArgs
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl DataSize for RuntimeArgs
impl DataSize for RuntimeArgs
Source§const IS_DYNAMIC: bool = true
const IS_DYNAMIC: bool = true
true
, the type has a heap size that can vary at runtime, depending on the actual value.Source§const STATIC_HEAP_SIZE: usize = 0usize
const STATIC_HEAP_SIZE: usize = 0usize
IS_DYNAMIC
is false, this is
the total amount of heap memory occupied by the value. Otherwise this is a lower bound.Source§fn estimate_heap_size(&self) -> usize
fn estimate_heap_size(&self) -> usize
Source§impl Debug for RuntimeArgs
impl Debug for RuntimeArgs
Source§impl Default for RuntimeArgs
impl Default for RuntimeArgs
Source§fn default() -> RuntimeArgs
fn default() -> RuntimeArgs
Source§impl<'de> Deserialize<'de> for RuntimeArgs
impl<'de> Deserialize<'de> for RuntimeArgs
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>,
Source§impl FromBytes for RuntimeArgs
impl FromBytes for RuntimeArgs
Source§impl Hash for RuntimeArgs
impl Hash for RuntimeArgs
Source§impl JsonSchema for RuntimeArgs
impl JsonSchema for RuntimeArgs
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moreSource§impl Ord for RuntimeArgs
impl Ord for RuntimeArgs
Source§fn cmp(&self, other: &RuntimeArgs) -> Ordering
fn cmp(&self, other: &RuntimeArgs) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for RuntimeArgs
impl PartialEq for RuntimeArgs
Source§impl PartialOrd for RuntimeArgs
impl PartialOrd for RuntimeArgs
Source§impl Serialize for RuntimeArgs
impl Serialize for RuntimeArgs
Source§impl ToBytes for RuntimeArgs
impl ToBytes for RuntimeArgs
Source§fn serialized_length(&self) -> usize
fn serialized_length(&self) -> usize
Vec<u8>
which would be returned from a successful call to
to_bytes()
or into_bytes()
. The data is not actually serialized, so this call is
relatively cheap.impl Eq for RuntimeArgs
impl StructuralPartialEq for RuntimeArgs
Auto Trait Implementations§
impl Freeze for RuntimeArgs
impl RefUnwindSafe for RuntimeArgs
impl Send for RuntimeArgs
impl Sync for RuntimeArgs
impl Unpin for RuntimeArgs
impl UnwindSafe for RuntimeArgs
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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
key
and return true
if they are equal.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
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>
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>
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