On this page
Struct std::net::AddrParseError
pub struct AddrParseError(/* private fields */);
An error which can be returned when parsing an IP address or a socket address.
This error is used as the error type for the FromStr
implementation for IpAddr
, Ipv4Addr
, Ipv6Addr
, SocketAddr
, SocketAddrV4
, and SocketAddrV6
.
Potential causes
AddrParseError
may be thrown because the provided string does not parse as the given type, often because it includes information only handled by a different address type.
use std::net::IpAddr;
let _foo: IpAddr = "127.0.0.1:8080".parse().expect("Cannot handle the socket port");
IpAddr
doesn’t handle the port. Use SocketAddr
instead.
use std::net::SocketAddr;
// No problem, the `panic!` message has disappeared.
let _foo: SocketAddr = "127.0.0.1:8080".parse().expect("unreachable panic");
Trait Implementations
impl Clone for AddrParseError
fn clone(&self) -> AddrParseError
fn clone_from(&mut self, source: &Self)
source
. Read more
impl Debug for AddrParseError
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
impl Display for AddrParseError
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>
impl Error for AddrParseError
fn description(&self) -> &str
fn source(&self) -> Option<&(dyn Error + 'static)>
fn cause(&self) -> Option<&dyn Error>
fn provide<'a>(&'a self, request: &mut Request<'a>)
error_generic_member_access
#99301)
impl PartialEq for AddrParseError
fn eq(&self, other: &AddrParseError) -> bool
self
and other
values to be equal, and is used by ==
.
fn ne(&self, other: &Rhs) -> bool
!=
. The default implementation is almost always sufficient, and should not be overridden without very good reason.
impl Eq for AddrParseError
impl StructuralEq for AddrParseError
impl StructuralPartialEq for AddrParseError
Auto Trait Implementations
impl RefUnwindSafe for AddrParseError
impl Send for AddrParseError
impl Sync for AddrParseError
impl Unpin for AddrParseError
impl UnwindSafe for AddrParseError
Blanket Implementations
impl<T> Any for T
where
T: 'static + ?Sized,
impl<T> Borrow<T> for T
where
T: ?Sized,
impl<T> BorrowMut<T> for T
where
T: ?Sized,
impl<T> From<T> for T
fn from(t: T) -> T
Returns the argument unchanged.
impl<T, U> Into<U> for T
where
U: From<T>,
fn into(self) -> U
Calls U::from(self)
.
That is, this conversion is whatever the implementation of From<T> for U
chooses to do.
impl<T> ToOwned for T
where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)
impl<T> ToString for T
where
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T
where
U: Into<T>,
type Error = Infallible
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for T
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/net/struct.AddrParseError.html