Expand description
Rust client for PopSub.
Client keeps a connection to a PopSub server and handles what every
application would otherwise have to: logging in and refreshing the token,
reconnecting with backoff (and knowing when not to, from the server’s
close code), resubscribing without gaps, resending confirmed publishes
without duplicating them, acknowledging QoS 1 messages, and making sure
each (topic, seq) reaches the application once.
Example:
use popsub_sdk::{Client, ClientConfig, Credentials, StartFrom};
let config = ClientConfig::new("ws://127.0.0.1:8080", Credentials::password("alice", "secret"))
.session("alice-laptop");
let client = Client::connect(config).await?;
let mut orders = client.subscribe("orders", StartFrom::Resume).await?;
let stored = client.publish_confirmed("orders", "order 42 shipped").await?;
println!("stored as seq {}", stored.seq);
while let Some(message) = orders.next().await {
println!("{} #{}: {}", message.topic, message.seq, message.payload);
}The protocol itself is in popsub_protocol and documented in the
repository’s docs/DESIGN.md section 4.
Structs§
- Admin
- The admin requests, borrowed from a
ClientwithClient::admin. - Client
- A connection to a PopSub server that reconnects on its own.
- Client
Config - Everything a
Clientneeds to connect. - Message
- A message delivered on a subscription.
- Published
- The result of a confirmed publish.
- Reconnect
Policy - How the client waits between reconnection attempts.
- Role
Spec - What an account may do, as admins see and set it.
- Subscription
- The messages of one subscribed topic, in
seqorder. - Topic
Grant - One topic pattern and what it allows.
- Topic
Info - A topic, as admins see it.
- User
Info - An account, as admins see it. Never includes the password or its hash.
Enums§
- Access
- What a topic grant allows.
- AckMode
- When QoS 1 messages are acknowledged.
- Close
Code - A close code the server sends, with what a client should do about it.
- Credentials
- How the client proves who it is.
- Encoding
- How a payload string encodes a message’s bytes. A payload with no encoding is the message’s text. The server stores and delivers the payload string unchanged, with its encoding beside it.
- Error
- Why a client call failed.
- Error
Code - Why a request failed. New codes may be added within a protocol version;
clients should treat an unknown code like
internal. - Event
- Something that happened to the connection or a subscription.
- Role
Kind - The kinds of account.
- Start
From - Where replay starts when a client subscribes.