pub enum Target {
Address(String),
HostPort(String, u16),
}Expand description
Target address for an SNMP client.
Specifies where to connect. Accepts either a combined address string or a separate host and port, which is useful when host and port are stored independently (avoids needing to format IPv6 bracket syntax).
§Examples
use async_snmp::Target;
// From a string (port defaults to 161 if omitted)
let t: Target = "192.168.1.1:161".into();
let t: Target = "switch.local".into();
// From a (host, port) tuple - no bracket formatting needed for IPv6
let t: Target = ("fe80::1", 161).into();
let t: Target = ("switch.local".to_string(), 162).into();
// From a SocketAddr
let t: Target = "192.168.1.1:161".parse::<std::net::SocketAddr>().unwrap().into();Variants§
Address(String)
A combined address string, e.g. "192.168.1.1:161" or "[::1]:162".
Port defaults to 161 if not specified.
HostPort(String, u16)
A separate host and port, e.g. ("fe80::1", 161).
Trait Implementations§
Source§impl From<SocketAddr> for Target
impl From<SocketAddr> for Target
Source§fn from(addr: SocketAddr) -> Self
fn from(addr: SocketAddr) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Target
impl RefUnwindSafe for Target
impl Send for Target
impl Sync for Target
impl Unpin for Target
impl UnsafeUnpin for Target
impl UnwindSafe for Target
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more