Skip to main content

ArgParser

Struct ArgParser 

Source
pub struct ArgParser<'a> { /* private fields */ }
Expand description

Helper for parsing command arguments

Implementations§

Source§

impl<'a> ArgParser<'a>

Source

pub fn new(args: &'a Value) -> Self

Create a new argument parser

Source

pub fn get_string(&self, name: &str) -> SdkResult<String>

Get a string argument

Source

pub fn get_optional_string(&self, name: &str) -> Option<String>

Get an optional string argument

Source

pub fn get_i64(&self, name: &str) -> SdkResult<i64>

Get an i64 argument

Source

pub fn get_optional_i64(&self, name: &str) -> Option<i64>

Get an optional i64 argument

Source

pub fn get_f64(&self, name: &str) -> SdkResult<f64>

Get a f64 argument

Source

pub fn get_optional_f64(&self, name: &str) -> Option<f64>

Get an optional f64 argument

Source

pub fn get_bool(&self, name: &str) -> SdkResult<bool>

Get a bool argument

Source

pub fn get_optional_bool(&self, name: &str) -> Option<bool>

Get an optional bool argument

Source

pub fn get_object(&self, name: &str) -> SdkResult<&Map<String, Value>>

Get a JSON object argument

Source

pub fn get_array(&self, name: &str) -> SdkResult<&Vec<Value>>

Get a JSON array argument

Source

pub fn parse<T: for<'de> Deserialize<'de>>(&self) -> SdkResult<T>

Parse the entire args as a specific type

Auto Trait Implementations§

§

impl<'a> Freeze for ArgParser<'a>

§

impl<'a> RefUnwindSafe for ArgParser<'a>

§

impl<'a> Send for ArgParser<'a>

§

impl<'a> Sync for ArgParser<'a>

§

impl<'a> Unpin for ArgParser<'a>

§

impl<'a> UnsafeUnpin for ArgParser<'a>

§

impl<'a> UnwindSafe for ArgParser<'a>

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> 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, 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.