Skip to main content

Crate popsub_sdk

Crate popsub_sdk 

Source
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 Client with Client::admin.
Client
A connection to a PopSub server that reconnects on its own.
ClientConfig
Everything a Client needs to connect.
Message
A message delivered on a subscription.
Published
The result of a confirmed publish.
ReconnectPolicy
How the client waits between reconnection attempts.
RoleSpec
What an account may do, as admins see and set it.
Subscription
The messages of one subscribed topic, in seq order.
TopicGrant
One topic pattern and what it allows.
TopicInfo
A topic, as admins see it.
UserInfo
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.
CloseCode
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.
ErrorCode
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.
RoleKind
The kinds of account.
StartFrom
Where replay starts when a client subscribes.