Trait app::OptValueParse
[−]
[src]
pub trait OptValueParse<'app>: Debug { fn into_opt_value(self) -> OptValue<'app>; fn is_bool(&self) -> bool; fn default(&self) -> Option<String>; fn parse(&mut self, opt_name: String, msg: &str) -> Result<(), String>; fn check(&self, opt_name: &str) -> Result<(), String>; }
You can use custom OptValue
by impl
it
Explain
into_opt_value(self)
convert it(&mut T
) toOptValue
.is_bool(&self)
like--help/-h
,they not have value follows it.so you should return
false
except value's type is&mut bool
(but it already defined).default(&self)
isOpt
's default value's str for help message printparse(&mut self, opt_name: String, msg: &str)
maintains the value, and return message byResult<(),String>
.opt_name
is currentOpt
's name,msg
is the&str
need to pasre.check(&self, opt_name: &str)
check value and return message byResult<(),String>
.
Suggestion
T
is suitable for options with default values.You can initialize it using the default value.
Option<T>
is suitable for necessary options.app
willcheck
them, isvalue.is_none()
,app
willexit(1)
after print error and help message.Vec<T>
is suitable a grout of comma-separated values of the same type.app
willcheck
them, isvalue.is_empty()
,app
willexit(1)
after print error and help message.You can initialize it using the default value.
"80" -> vec[80]
",80," -> vec[80]
",80,," -> vec[80]
"8080,8000,80," -> Vec[8080,8000,80]
Required Methods
fn into_opt_value(self) -> OptValue<'app>
fn is_bool(&self) -> bool
fn default(&self) -> Option<String>
fn parse(&mut self, opt_name: String, msg: &str) -> Result<(), String>
fn check(&self, opt_name: &str) -> Result<(), String>
Implementors
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut bool
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut String
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut char
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut usize
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut u8
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut u16
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut u32
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut u64
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut isize
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut i8
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut i16
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut i32
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut i64
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut f32
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut f64
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut IpAddr
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Ipv4Addr
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Ipv6Addr
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut SocketAddr
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut SocketAddrV4
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut SocketAddrV6
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<char>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<String>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<bool>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<usize>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<u8>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<u16>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<u32>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<u64>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<isize>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<i8>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<i16>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<i32>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<i64>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<f32>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<f64>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<IpAddr>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<Ipv4Addr>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<Ipv6Addr>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<SocketAddr>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<SocketAddrV4>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Option<SocketAddrV6>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<char>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<String>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<bool>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<usize>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<u8>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<u16>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<u32>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<u64>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<isize>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<i8>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<i16>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<i32>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<i64>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<f32>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<f64>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<IpAddr>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<Ipv4Addr>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<Ipv6Addr>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<SocketAddr>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<SocketAddrV4>
impl<'app, 's: 'app> OptValueParse<'app> for &'s mut Vec<SocketAddrV6>