cute::val

Trait ValueParser

Source
pub trait ValueParser {
    type Error;
    type Out<'a>;

    // Required method
    fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>;
}
Expand description

A trait for parsing command line argument values into various types

This trait provides a unified interface for converting string values from command line arguments into different Rust types. Each implementation handles type-specific parsing logic and error reporting.

Required Associated Types§

Source

type Error

Source

type Out<'a>

Required Methods§

Source

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ValueParser for &str

Implementation of ValueParser for string slices

Returns a reference to the input string’s contents

Source§

type Error = Error

Source§

type Out<'a> = &'a str

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Source§

impl ValueParser for bool

Implementation of ValueParser for boolean values

Returns true if any value is present, false otherwise

Source§

type Error = Error

Source§

type Out<'a> = bool

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Source§

impl ValueParser for f64

Source§

type Error = Error

Source§

type Out<'a> = f64

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Source§

impl ValueParser for i8

Source§

type Error = Error

Source§

type Out<'a> = i8

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Source§

impl ValueParser for i16

Source§

type Error = Error

Source§

type Out<'a> = i16

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Source§

impl ValueParser for i32

Source§

type Error = Error

Source§

type Out<'a> = i32

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Source§

impl ValueParser for i64

Source§

type Error = Error

Source§

type Out<'a> = i64

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Source§

impl ValueParser for i128

Source§

type Error = Error

Source§

type Out<'a> = i128

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Source§

impl ValueParser for isize

Source§

type Error = Error

Source§

type Out<'a> = isize

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Source§

impl ValueParser for u8

Source§

type Error = Error

Source§

type Out<'a> = u8

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Source§

impl ValueParser for u16

Source§

type Error = Error

Source§

type Out<'a> = u16

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Source§

impl ValueParser for u32

Source§

type Error = Error

Source§

type Out<'a> = u32

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Source§

impl ValueParser for u64

Source§

type Error = Error

Source§

type Out<'a> = u64

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Source§

impl ValueParser for u128

Source§

type Error = Error

Source§

type Out<'a> = u128

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Source§

impl ValueParser for usize

Source§

type Error = Error

Source§

type Out<'a> = usize

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Source§

impl ValueParser for String

Implementation of ValueParser for String values

Returns a cloned String from the input value

Source§

type Error = Error

Source§

type Out<'a> = String

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Source§

impl ValueParser for Path

Implementation of ValueParser for Path references

Returns a reference to a Path created from the input string

Source§

type Error = Error

Source§

type Out<'a> = &'a Path

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Source§

impl ValueParser for PathBuf

Implementation of ValueParser for PathBuf values

Converts the input string into a PathBuf

Source§

type Error = Error

Source§

type Out<'a> = PathBuf

Source§

fn parse(val: Option<&String>) -> Result<Self::Out<'_>, Self::Error>

Implementors§