Expand description
Aldrin client library
This library implements the client side of the Aldrin specification and can be used to connect to Aldrin brokers. It is fully asynchronous (async/await) and doesn’t depend on any specific async runtime.
Parts of this library should be considered low-level building blocks for the code that can be auto-generated from Aldrin schemas. As an example, performing a function call on a service requires knowing the function’s id and uses a polymorphic type to encode the function’s arguments. It is generally recommended to rely on the more ergonomic auto-generated code instead.
The first entry point is the Client and it’s connect
method. Clients are parameterized over an
AsyncTransport, which abstracts the low-level
details of a transport, like e.g. TCP/IP.
After establishing a connection, the resulting Client must be continuously polled (through
Client::run). One way to achieve this is to “spawn” it with an async runtime of your
choice. Alternatively, it can also be polled manually.
While the Client is being polled, all interaction with it happens through a Handle,
which can be acquired with Client::handle. The Client will automatically shut down (as
in, the Client::run future will complete) when the last Handle has been dropped.
§Examples
use aldrin::Client;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
// Create an AsyncTransport for connecting to the broker.
// let async_transport = ...
// Connect to the broker:
let client = Client::connect(async_transport).await?;
// Acquire a handle and spawn the client:
let handle = client.handle().clone();
let join = tokio::spawn(client.run());
// The client is now fully connected and can be interacted with through the handle.
// Shut down client:
handle.shutdown();
join.await??;
Ok(())
}Re-exports§
pub use discoverer::Discoverer;pub use discoverer::DiscovererEvent;pub use discoverer::DiscovererEventKind;pub use error::Error;pub use aldrin_core as core;
Modules§
- discoverer
- Contains the
Discovererand its related types. - error
- Error types.
- low_
level - Low-level types
Macros§
Structs§
- BusListener
- Monitors the bus for the creation and destruction of objects and services.
- Call
- Pending call.
- Channel
Builder - Builder type for creating channels.
- Client
- Aldrin client used to connect to a broker.
- Client
Builder - Connects to a broker and constructs a
Client. - Event
- Event emitted by a service.
- Handle
- Handle to a client.
- Lifetime
- Notifies when a
LifetimeScopeends. - Lifetime
Id - Id of a scope’s lifetime.
- Lifetime
Scope - A scope that notifies other clients when ends.
- Object
- Owned object on the bus.
- Pending
Receiver - A receiver that is waiting for the channel to be established.
- Pending
Reply - Future to await the result of a call.
- Pending
Sender - A sender that is waiting for the channel to be established.
- Promise
- Replies to a pending call.
- Property
- Tracks some state of a service.
- Receiver
- The receiving end of an established channel.
- Reply
- Reply of a call.
- Sender
- The sending end of an established channel.
- Unbound
Receiver - A receiver that isn’t bound to any client.
- Unbound
Sender - A sender that isn’t bound to any client.
- Unclaimed
Receiver - A receiver that hasn’t been claimed yet by a client.
- Unclaimed
Sender - A sender that hasn’t been claimed yet by a client.
- Unknown
Call - An unknown pending call.
- Unknown
Event - An unknown event emitted by a service.
Derive Macros§
- Deserialize
- Derive macro for the
Deserializetrait. - Deserialize
Key - Derive macro for the
DeserializeKeytrait. - Introspectable
- Derive macro for the
Introspectabletrait. - KeyTag
- Derive macro for the
KeyTagtrait. - Primary
KeyTag - Derive macro for the
PrimaryKeyTagtrait. - Primary
Tag - Derive macro for the
PrimaryTagtrait. - RefType
- Derive macro for ref types.
- Serialize
- Derive macro for the
Serializetrait. - Serialize
Key - Derive macro for the
SerializeKeytrait. - Tag
- Derive macro for the
Tagtrait.