pub struct ReqSocket<T: Transport<A>, A: Address> { /* private fields */ }Expand description
The request socket.
Implementations§
Source§impl<T> ReqSocket<T, SocketAddr>where
T: Transport<SocketAddr>,
impl<T> ReqSocket<T, SocketAddr>where
T: Transport<SocketAddr>,
Sourcepub async fn connect(
&mut self,
addr: impl ToSocketAddrs,
) -> Result<(), ReqError>
pub async fn connect( &mut self, addr: impl ToSocketAddrs, ) -> Result<(), ReqError>
Connects to the target address with the default options.
Sourcepub fn connect_sync(&mut self, addr: SocketAddr)
pub fn connect_sync(&mut self, addr: SocketAddr)
Starts connecting to a resolved socket address. This is essentially a Self::connect
variant that doesn’t error or block due to DNS resolution and blocking connect.
Source§impl<T, A> ReqSocket<T, A>
impl<T, A> ReqSocket<T, A>
pub fn new(transport: T) -> Self
pub fn with_options(transport: T, options: ReqOptions) -> Self
Sourcepub fn with_compressor<C: Compressor + 'static>(self, compressor: C) -> Self
pub fn with_compressor<C: Compressor + 'static>(self, compressor: C) -> Self
Sets the message compressor for this socket.
Sourcepub fn with_connection_hook<H>(self, hook: H) -> Selfwhere
H: ConnectionHook<T::Io>,
pub fn with_connection_hook<H>(self, hook: H) -> Selfwhere
H: ConnectionHook<T::Io>,
Sets the connection hook for this socket.
The connection hook is called after connecting to the server, before the connection is used for request/reply communication.
§Panics
Panics if the driver has already been started (i.e., after calling connect).
Sourcepub fn stats(&self) -> &SocketStats<ReqStats>
pub fn stats(&self) -> &SocketStats<ReqStats>
Returns the socket stats.
Sourcepub fn transport_stats(&self) -> Guard<Arc<T::Stats>>
pub fn transport_stats(&self) -> Guard<Arc<T::Stats>>
Get the latest transport-level stats snapshot.
pub async fn request(&self, message: Bytes) -> Result<Bytes, ReqError>
Sourcepub async fn try_connect(&mut self, endpoint: A) -> Result<(), ReqError>
pub async fn try_connect(&mut self, endpoint: A) -> Result<(), ReqError>
Tries to connect to the target endpoint with the default options. A ReqSocket can only be connected to a single address.
Auto Trait Implementations§
impl<T, A> Freeze for ReqSocket<T, A>where
T: Freeze,
impl<T, A> !RefUnwindSafe for ReqSocket<T, A>
impl<T, A> Send for ReqSocket<T, A>
impl<T, A> Sync for ReqSocket<T, A>
impl<T, A> Unpin for ReqSocket<T, A>
impl<T, A> UnsafeUnpin for ReqSocket<T, A>where
T: UnsafeUnpin,
impl<T, A> !UnwindSafe for ReqSocket<T, A>
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