Struct ockam_transport_uds::UdsTransport
source · pub struct UdsTransport { /* private fields */ }
Expand description
High level management interface for UDS transports
Be aware that only one UdsTransport
can exist per node, as it
registers itself as a router for the UDS
address type. Multiple
calls to UdsTransport::create
will fail.
To listen for incoming connections use
uds.listen()
.
To register additional connections on an already initialised
UdsTransport
, use uds.connect()
.
This step is optional because the underlying UdsRouter is capable of lazily
establishing a connection upon arrival of an initial message.
use ockam_transport_uds::UdsTransport;
let uds = UdsTransport::create(&ctx).await?;
uds.listen("/tmp/example-socket").await?; // Listen on socket `/tmp/example-socket`
uds.connect("/tmp/other-socket").await?; // And connect to `/tmp/other-socket`
The same UdsTransport
can also bind to multiple sockets.
use ockam_transport_uds::UdsTransport;
let uds = UdsTransport::create(&ctx).await?;
uds.listen("/tmp/socket-one").await?; // Listen on `/tmp/socket-one`
uds.listen("/tmp/socket-two").await?; // Listen on `/tmp/socket-two`
Implementations§
source§impl UdsTransport
impl UdsTransport
sourcepub async fn create(ctx: &Context) -> Result<Self>
pub async fn create(ctx: &Context) -> Result<Self>
Creates a a UDS Router and registers it with the given node Context
sourcepub async fn connect<S: AsRef<str>>(&self, peer: S) -> Result<Address>
pub async fn connect<S: AsRef<str>>(&self, peer: S) -> Result<Address>
Connects the UdsTransport
to the given socket peer.
use ockam_transport_uds::UdsTransport;
let uds = UdsTransport::create(&ctx).await?;
uds.connect("/tmp/socket-name").await?;
sourcepub async fn disconnect<S: AsRef<str>>(&self, peer: S) -> Result<()>
pub async fn disconnect<S: AsRef<str>>(&self, peer: S) -> Result<()>
Disconnects the UdsTransport
from the given socket peer.
use ockam_transport_uds::UdsTransport;
let uds = UdsTransport::create(&ctx).await?;
uds.connect("/tmp/socket-name").await?;
uds.disconnect("/tmp/socket-name").await?;
sourcepub async fn listen<S: AsRef<str>>(&self, bind_addr: S) -> Result<SocketAddr>
pub async fn listen<S: AsRef<str>>(&self, bind_addr: S) -> Result<SocketAddr>
Binds the UdsTransport
to listen and accept incoming connection requests to the given socket.
use ockam_transport_uds::UdsTransport;
let uds = UdsTransport::create(&ctx).await?;
uds.listen("/tmp/socket-name").await?;