Struct structopt_flags::HostV4Opt
source · pub struct HostV4Opt { /* private fields */ }Expand description
This struct provides the --host and -H cli option to get an IPv4 address
No default is provided
extern crate structopt_flags;
#[macro_use]
extern crate structopt;
use std::net::Ipv4Addr;
use structopt::StructOpt;
use structopt_flags::GetWithDefault; // to access get_with_default
#[derive(Debug, StructOpt)]
#[structopt(name = "ipv4_opt", about = "An example using the HostV4Opt option")]
struct Opt {
#[structopt(flatten)]
host_ip: structopt_flags::HostV4Opt,
}
fn main() {
let opt = Opt::from_args();
let ipv4 = opt.host_ip.get_with_default(Ipv4Addr::new(127,0,0,1));
}Trait Implementations
sourceimpl GetWithDefault for HostV4Opt
impl GetWithDefault for HostV4Opt
sourceimpl StructOpt for HostV4Opt
impl StructOpt for HostV4Opt
sourcefn from_clap(matches: &ArgMatches<'_>) -> Self
fn from_clap(matches: &ArgMatches<'_>) -> Self
Creates the struct from
clap::ArgMatches. It cannot fail
with a parameter generated by clap by construction. Read moresourcefn from_args() -> Selfwhere
Self: Sized,
fn from_args() -> Selfwhere
Self: Sized,
Gets the struct from the command line arguments. Print the
error message and quit the program in case of failure. Read more
sourcefn from_iter<I>(iter: I) -> Selfwhere
Self: Sized,
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString> + Clone,
fn from_iter<I>(iter: I) -> Selfwhere
Self: Sized,
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString> + Clone,
Gets the struct from any iterator such as a
Vec of your making.
Print the error message and quit the program in case of failure. Read moresourcefn from_iter_safe<I>(iter: I) -> Result<Self, Error>where
Self: Sized,
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString> + Clone,
fn from_iter_safe<I>(iter: I) -> Result<Self, Error>where
Self: Sized,
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString> + Clone,
Gets the struct from any iterator such as a
Vec of your making. Read moreAuto Trait Implementations
impl RefUnwindSafe for HostV4Opt
impl Send for HostV4Opt
impl Sync for HostV4Opt
impl Unpin for HostV4Opt
impl UnwindSafe for HostV4Opt
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more