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. Client
s 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 error::Error;
pub use aldrin_core as core;
Modules§
- Error types.
- Low-level types
Macros§
- Generates code from an Aldrin schema.
Structs§
- Monitors the bus for the creation and destruction of objects and services.
- Aldrin client used to connect to a broker.
- Discovers objects with multiple services on the bus.
- Builder for
Discoverer
s. - Entry of a
Discoverer
. - Iterator over all found objects corresponding to a specific key.
- Event emitted by
Discoverer
s. - Iterator over all found objects of a
Discoverer
. - Item type when iterating over a
Discoverer
orDiscovererEntry
. - Handle to a client.
- Notifies when a
LifetimeScope
ends. - Id of a scope’s lifetime.
- A scope that notifies other clients when ends.
- Owned object on the bus.
- A claimed receiver that is waiting for the channel to become established.
- A claimed sender that is waiting for the channel to become established.
- Replies to a pending call.
- The receiving end of an established channel.
- Future to await the result of a call.
- The sending end of an established channel.
- A receiver that is not bound to any particular client.
- A sender that is not bound to any particular client.
- A receiver that hasn’t been claimed yet.
- A sender that hasn’t been claimed yet.
Enums§
- Specifies whether an object was created or destroyed.