Struct casper_types::RuntimeArgs
source · 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>where
F: FnOnce(&mut RuntimeArgs) -> Result<(), CLValueError>,
pub fn try_new<F>(func: F) -> Result<RuntimeArgs, CLValueError>where F: FnOnce(&mut RuntimeArgs) -> Result<(), 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>where
K: Into<String>,
V: CLTyped + ToBytes,
pub fn insert<K, V>(&mut self, key: K, value: V) -> Result<(), CLValueError>where K: Into<String>, V: CLTyped + ToBytes,
Inserts a new named argument into the collection.
sourcepub fn insert_cl_value<K>(&mut self, key: K, cl_value: CLValue)where
K: Into<String>,
pub fn insert_cl_value<K>(&mut self, key: K, cl_value: CLValue)where K: Into<String>,
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 CLTypes 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 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 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§fn eq(&self, other: &RuntimeArgs) -> bool
fn eq(&self, other: &RuntimeArgs) -> bool
self and other values to be equal, and is used
by ==.source§impl PartialOrd for RuntimeArgs
impl PartialOrd for RuntimeArgs
source§fn partial_cmp(&self, other: &RuntimeArgs) -> Option<Ordering>
fn partial_cmp(&self, other: &RuntimeArgs) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§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.