Struct clap_port_flag::Port
source · [−]pub struct Port { /* private fields */ }
Expand description
Easily add a --port
flag to clap.
Usage
#[derive(Debug, clap::Parser)]
struct Cli {
#[clap(flatten)]
port: clap_port_flag::Port,
}
Implementations
sourceimpl Port
impl Port
Create 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.
(This only applies if the “fd” feature is enabled)
sourcepub fn bind(&self) -> Result<TcpListener>
pub fn bind(&self) -> Result<TcpListener>
Create a TCP socket from the passed in port or file descriptor.
sourcepub fn bind_or(&self, port: u16) -> Result<TcpListener>
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
sourceimpl Args for Port
impl Args for Port
sourcefn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
sourcefn augment_args_for_update<'b>(__clap_app: Command) -> Command
fn augment_args_for_update<'b>(__clap_app: Command) -> Command
sourcefn group_id() -> Option<Id>
fn group_id() -> Option<Id>
Report the
ArgGroup::id
for this set of argumentssourceimpl FromArgMatches for Port
impl FromArgMatches for Port
sourcefn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
sourcefn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches
) -> Result<Self, Error>
fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches
) -> Result<Self, Error>
sourcefn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches
) -> Result<(), Error>
fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches
) -> Result<(), Error>
Assign values from
ArgMatches
to self
.sourcefn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches
) -> Result<(), Error>
fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches
) -> Result<(), Error>
Assign values from
ArgMatches
to self
.Auto Trait Implementations
impl RefUnwindSafe for Port
impl Send for Port
impl Sync for Port
impl Unpin for Port
impl UnwindSafe for Port
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