Function ddmw_client::conn::connect
source · pub async fn connect(
pa: &ProtAddr,
auth: Option<&Auth>
) -> Result<Framed<Stream, Codec>, Error>
Expand description
Connect to one of the DDMW core’s client interfaces and optionally attempt to authenticate.
If ProtAddr::Tcp()
is passed into the pa
argument an TCP/IP connection
will be attempted. If ProtAddr::Uds()
(currently only available on
unix-like platforms) is used a unix local domain socket connection will be
attempted.
If auth
has Some
value, an authentication will be attempted after
successful connection. If the authentication fails the entire connection
will fail. To be able to keep the connection up in case the authentication
fails, pass None
to the auth
argument and manually authenticate in the
application.
Examples
use ddmw_client::conn;
async fn test() {
let pa = protwrap::ProtAddr::Tcp("127.0.0.1:8777".to_string());
let conn = conn::connect(&pa, None).await.expect("Unable to connect");
}