pub struct Dialer(/* private fields */);
Expand description
A custom address or dialer for connecting to a host.
A dialer can be created from a URI-like string using FromStr
. The
following URI schemes are supported:
tcp
: Connect to a TCP address and port pair, liketcp:127.0.0.1:8080
.unix
: Connect to a Unix socket located on the file system, likeunix:/path/to/my.sock
. This is only supported on Unix.
The Default
dialer uses the hostname and port specified in each request
as normal.
§Examples
Connect to a Unix socket URI:
use isahc::config::Dialer;
let unix_socket = "unix:/path/to/my.sock".parse::<Dialer>()?;
Implementations§
Source§impl Dialer
impl Dialer
Sourcepub fn ip_socket(addr: impl Into<SocketAddr>) -> Self
pub fn ip_socket(addr: impl Into<SocketAddr>) -> Self
Connect to the given IP socket.
Any value that can be converted into a SocketAddr
can be given as an
argument; check the SocketAddr
documentation for a complete list.
§Examples
use isahc::config::Dialer;
use std::net::Ipv4Addr;
let dialer = Dialer::ip_socket((Ipv4Addr::LOCALHOST, 8080));
use isahc::config::Dialer;
use std::net::SocketAddr;
let dialer = Dialer::ip_socket("0.0.0.0:8765".parse::<SocketAddr>()?);
Sourcepub fn unix_socket(path: impl Into<PathBuf>) -> Self
pub fn unix_socket(path: impl Into<PathBuf>) -> Self
Connect to a Unix socket described by a file.
The path given is not checked ahead of time for correctness or that the socket exists. If the socket is invalid an error will be returned when a request attempt is made.
§Examples
use isahc::config::Dialer;
let docker = Dialer::unix_socket("/var/run/docker.sock");
§Availability
This function is only available on Unix.
Trait Implementations§
Source§impl From<SocketAddr> for Dialer
impl From<SocketAddr> for Dialer
Source§fn from(socket_addr: SocketAddr) -> Self
fn from(socket_addr: SocketAddr) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Dialer
impl RefUnwindSafe for Dialer
impl Send for Dialer
impl Sync for Dialer
impl Unpin for Dialer
impl UnwindSafe for Dialer
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