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§
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.
- Discoverer
- Discovers objects with multiple services on the bus.
- Discoverer
Builder - Builder for
Discoverer
s. - Discoverer
Entry - Entry of a
Discoverer
. - Discoverer
Entry Iter - Iterator over all found objects corresponding to a specific key.
- Discoverer
Event - Event emitted by
Discoverer
s. - Discoverer
Iter - Iterator over all found objects of a
Discoverer
. - Discoverer
Iter Entry - Item type when iterating over a
Discoverer
orDiscovererEntry
. - Event
- Event emitted by a service.
- Handle
- Handle to a client.
- Lifetime
- Notifies when a
LifetimeScope
ends. - 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.
Enums§
- Discoverer
Event Kind - Specifies whether an object was created or destroyed.
Derive Macros§
- AsSerialize
Arg - Derive macro for the
AsSerializeArg
trait. - Deserialize
- Derive macro for the
Deserialize
trait. - Deserialize
Key - Derive macro for the
DeserializeKey
trait. - Introspectable
- Derive macro for the
Introspectable
trait. - KeyType
Of - Derive macro for the
KeyTypeOf
trait. - Serialize
- Derive macro for the
Serialize
trait. - Serialize
Key - Derive macro for the
SerializeKey
trait.