Struct structopt_flags::HostOpt
source · pub struct HostOpt { /* private fields */ }Expand description
This struct provides the --host and -H cli option to get ageneric IP address
No default is provided
extern crate structopt_flags;
#[macro_use]
extern crate structopt;
use std::net::{IpAddr,Ipv6Addr};
use structopt::StructOpt;
use structopt_flags::GetWithDefault; // to access get_with_default
#[derive(Debug, StructOpt)]
#[structopt(name = "ip_opt", about = "An example using the HostOpt option")]
struct Opt {
#[structopt(flatten)]
host_ip: structopt_flags::HostOpt,
}
fn main() {
let opt = Opt::from_args();
let ip = opt.host_ip.get_with_default(IpAddr::V6(Ipv6Addr::new(0,0,0,0,0,0,0,1)));
}Trait Implementations
sourceimpl GetWithDefault for HostOpt
impl GetWithDefault for HostOpt
sourceimpl StructOpt for HostOpt
impl StructOpt for HostOpt
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 HostOpt
impl Send for HostOpt
impl Sync for HostOpt
impl Unpin for HostOpt
impl UnwindSafe for HostOpt
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