pub struct ClientConnection<T, C>where
T: Initiator<Connection = C>,
C: Connection,{ /* private fields */ }Expand description
Manages the connection to the server, including authentication and reconnection logic.
This struct handles the lifecycle of a connection to the server, including initial authentication, automatic reconnection on failures, and connection state management.
Implementations§
Source§impl<T, C> ClientConnection<T, C>where
T: Initiator<Connection = C>,
C: Connection,
impl<T, C> ClientConnection<T, C>where
T: Initiator<Connection = C>,
C: Connection,
Sourcepub async fn new(
transport: T,
secret: Secret,
options: Option<Bytes>,
) -> Result<Self>
pub async fn new( transport: T, secret: Secret, options: Option<Bytes>, ) -> Result<Self>
Creates a new ClientConnection and establishes a connection to the server.
This involves performing authentication with the server.
Sourcepub async fn open_bidirectional(
&self,
dest_addr: Address,
) -> Result<BufferedStream<C::Stream>>
pub async fn open_bidirectional( &self, dest_addr: Address, ) -> Result<BufferedStream<C::Stream>>
Opens a new bidirectional stream for TCP-like communication.
This method negotiates a new stream with the server, which will then connect to the specified destination address. It waits for the server’s connection response before returning, ensuring proper TCP state handling.
The returned stream is wrapped in a BufferedStream to ensure that any
data remaining in the protocol framing buffer is read first, preventing
data loss when transitioning from message-based to raw stream communication.
Sourcepub fn connection(&self) -> Guard<Arc<C>>
pub fn connection(&self) -> Guard<Arc<C>>
Gets a reference to the current connection.