Skip to main content

Module connection

Module connection 

Source
Expand description

Contains connection related API.

The Connection type provides a low-level API for sending and receiving Varlink messages. For most use cases, you’ll want to use the higher-level proxy and service attribute macros instead, which generate type-safe client and server code respectively.

§Client Usage with proxy Macro

The proxy macro generates methods on Connection<S> for calling remote service methods:

#[zlink_core::proxy(
    interface = "org.example.Calculator",
    // Not needed in the real code because you'll use `proxy` through `zlink` crate.
    crate = "zlink_core",
)]
trait CalculatorProxy {
    async fn add(&mut self, a: f64, b: f64) -> zlink_core::Result<Result<f64, CalcError>>;
}

#[derive(Debug, zlink_core::ReplyError)]
#[zlink(
    interface = "org.example.Calculator",
    // Not needed in the real code because you'll use `ReplyError` through `zlink` crate.
    crate = "zlink_core",
)]
enum CalcError {}

§Server Usage with service Macro

The service macro generates the Service trait implementation. See the service macro documentation for details and examples.

§Low-Level API

For advanced use cases that require more control, the Connection type provides direct access to message sending and receiving via methods like Connection::send_call, Connection::receive_reply, and Connection::chain_call for pipelining.

Re-exports§

pub use chain::Chain;
pub use socket::Socket;

Modules§

chain
Chain method calls.
socket
The low-level Socket read and write traits.

Structs§

Connection
A connection.
Credentials
Credentials of a peer connection.
Gid
gid_t—A Unix group ID.
Pid
pid_t—A non-zero Unix process ID.
ReadConnection
A connection that can only be used for reading.
Uid
uid_t—A Unix user ID.
WriteConnection
A connection.