Struct clap_port_flag::Port [−][src]
pub struct Port { /* fields omitted */ }Easily add a --port flag to Structopt.
Usage
extern crate clap_port_flag; #[macro_use] extern crate structopt; use structopt::StructOpt; use clap_port_flag::Port; #[derive(Debug, StructOpt)] struct Cli { #[structopt(flatten)] port: Port, }
Methods
impl Port[src]
impl PortCreate a TCP socket.
Panics
If a file descriptor was passed directly, we call the unsafe
TcpListener::from_raw_fd() method, which may panic if a non-existent file
descriptor was passed.
pub fn bind(&self) -> Result<TcpListener>[src]
pub fn bind(&self) -> Result<TcpListener>Create a TCP socket from the passed in port or file descriptor.
pub fn bind_or(&self, port: u16) -> Result<TcpListener>[src]
pub fn bind_or(&self, port: u16) -> Result<TcpListener>Create a TCP socket by calling to .bind(). If it fails, create a socket
on port.
Useful to create a default socket to listen to if none was passed.
Trait Implementations
impl StructOpt for Port[src]
impl StructOpt for Portfn clap<'a, 'b>() -> App<'a, 'b>[src]
fn clap<'a, 'b>() -> App<'a, 'b>Returns the corresponding clap::App.
fn from_clap(matches: &ArgMatches) -> Self[src]
fn from_clap(matches: &ArgMatches) -> SelfCreates the struct from clap::ArgMatches. It cannot fail with a parameter generated by clap by construction. Read more
fn from_args() -> Self[src]
fn from_args() -> SelfGets the struct from the command line arguments. Print the error message and quit the program in case of failure. Read more
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString>,
<I as IntoIterator>::Item: Clone, [src]
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString>,
<I as IntoIterator>::Item: 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 more
fn from_iter_safe<I>(iter: I) -> Result<Self, Error> where
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString>,
<I as IntoIterator>::Item: Clone, [src]
fn from_iter_safe<I>(iter: I) -> Result<Self, Error> where
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString>,
<I as IntoIterator>::Item: Clone, Gets the struct from any iterator such as a Vec of your making. Read more
impl Debug for Port[src]
impl Debug for Port