Skip to main content

CallArgs

Struct CallArgs 

Source
pub struct CallArgs(/* private fields */);
Expand description

Represents a collection of arguments passed to a smart contract entrypoint call.

Wraps casper’s RuntimeArgs.

Implementations§

Source§

impl CallArgs

Source

pub fn new() -> Self

Creates a new no-args instance.

Source

pub fn insert<K, V>(&mut self, key: K, value: V)
where K: Into<String>, V: CLTyped + ToBytes,

Inserts a new empty arg into the collection.

Source

pub fn arg_names(&self) -> Vec<String>

Retrieves a vector of argument names.

Source

pub fn as_casper_runtime_args(&self) -> &RuntimeArgs

Return Casper’s RuntimeArgs.

Methods from Deref<Target = RuntimeArgs>§

Source

pub fn get(&self, name: &str) -> Option<&CLValue>

Gets an argument by its name.

Source

pub fn len(&self) -> usize

Gets the length of the collection.

Source

pub fn is_empty(&self) -> bool

Returns true if the collection of arguments is empty.

Source

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.

Source

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.

Source

pub fn to_values(&self) -> Vec<&CLValue>

Returns all the values of the named args.

Source

pub fn named_args(&self) -> impl Iterator<Item = &NamedArg>

Returns an iterator of references over all arguments in insertion order.

Source

pub fn named_args_mut(&mut self) -> impl Iterator<Item = &mut NamedArg>

Returns an iterator of mutable references over all arguments in insertion order.

Source

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 CLTyped for CallArgs

Source§

fn cl_type() -> CLType

The CLType of Self.
Source§

impl Clone for CallArgs

Source§

fn clone(&self) -> CallArgs

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CallArgs

Source§

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

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

impl Default for CallArgs

Source§

fn default() -> CallArgs

Returns the “default value” for a type. Read more
Source§

impl Deref for CallArgs

Source§

type Target = RuntimeArgs

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for CallArgs

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl FromBytes for CallArgs

Source§

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

Deserializes the slice into Self.
Source§

fn from_vec(bytes: Vec<u8>) -> Result<(Self, Vec<u8>), Error>

Deserializes the Vec<u8> into Self.
Source§

impl ToBytes for CallArgs

Source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

Serializes &self to a Vec<u8>.
Source§

fn serialized_length(&self) -> usize

Returns the length of the 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.
Source§

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

Consumes self and serializes to a Vec<u8>.
Source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

Writes &self into a mutable writer.

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> OdraType for T
where T: CLTyped + ToBytes + FromBytes,

Source§

fn serialize(&self) -> Option<Vec<u8>>

Source§

fn deserialize(bytes: &[u8]) -> Option<Self>

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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, 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> Typed for T
where T: CLTyped,