Skip to main content

Crate obby_client

Crate obby_client 

Source
Expand description

The Obby client engine.

One Client is one connection. It owns the registration state machine, the negotiated capabilities and the client model. It opens no socket, reads no clock and renders nothing: the host pushes bytes and time in, and drains bytes and events out.

use obby_client::{Client, Config, Event};

let mut client = Client::new(Config::new("mynick"));
client.handle_connected();

// whatever the host wrote is now waiting to go on the wire
let first = client.poll_transmit().expect("registration starts on connect");
assert!(first.starts_with(b"CAP LS 302"));

client.handle_bytes(b":irc.example.org CAP * LS :sasl multi-prefix\r\n");
client.handle_bytes(b":irc.example.org CAP * ACK :multi-prefix\r\n");
assert!(matches!(client.poll_event(), Some(Event::CapabilitiesAcknowledged { .. })));

Re-exports§

pub use obby_proto as proto;

Structs§

Bot
What the server knows about a bot in a channel.
BotCommand
One command a bot offers.
Bots
The bots we know about, keyed by their folded nick.
Capabilities
What the server offers and what we hold.
Capability
One capability the server advertised, with the value it carried if any.
Channel
A channel we are in.
ChatMessage
One message, as the model holds it.
ChunkMeta
The chunk-correlation fields riding alongside a split sdp value.
Client
One connection.
Commands
The set of commands the server says we may currently use.
Config
What a host needs to give the engine before it can connect.
Conversation
A private conversation with one other person.
Fingerprint
A peer’s identity fingerprint: the first 16 bytes of SHA-256(signing_public_key).
Frag
The fragmentation envelope the real client uses to split a frame too large for one wire line, on either carrier. The working client sends this, and no spec text describes it.
HandshakeResponse
The responder’s answer, decoded from the wire’s base64 JSON blob that accept carries as response.
Identity
A long-term identity: an X25519 agreement key and an Ed25519 signing key, generated once and kept for the lifetime of an account.
IdentityPublic
The public half of an Identity: an X25519 agreement key (ik) and an Ed25519 signing key (sik), exactly as they travel inside PreKeyBundle and HandshakeResponse.
Invitation
An invitation link to the network or to one channel.
LinkPreview
A preview of a link someone posted, built by the server and attached to the message.
LocalUser
Who we are on this connection.
Membership
What one member holds in one channel.
MessageKey
Where a message is ordered and how it is found again.
MessageLog
The messages of one channel or conversation, ordered and bounded.
Model
Everything the connection knows.
Now
A moment in time, as the host’s two clocks see it.
Participant
One participant’s state within a Room.
PeerTrust
Trust-on-first-use bookkeeping for one peer.
PendingOffer
The offering side’s freshly generated prekeys, retained locally until the peer’s accept arrives. Never sent as-is; PreKeyBundle is the public half that is.
Person
Someone we know about, held once however many channels we share.
PreKeyBundle
A responder-published prekey bundle, decoded from the wire’s base64 JSON blob that init carries as bundle. Field names match the wire exactly.
Ratchet
One party’s half of a Double Ratchet session: a sending chain, a receiving chain, and the skipped-key store that lets messages arrive out of order.
RatchetMessage
One Double Ratchet message: a header carried as authenticated associated data, and an AEAD ciphertext.
Room
The state of one voice room: who is in it, their kind of channel, and every participant’s mic, video, speaking, deaf, screen and hand state and role.
Scram
An exchange in progress.
SdpChunk
One numbered slice of a split offer/answer frame.
SdpReassembler
A bounded buffer that reassembles offer/answer frames split across chunks.
Session
One pairwise end-to-end encrypted conversation.
TrackHint
A hint from the SFU mapping one negotiated media line to the member it belongs to.
TurnCredentials
TURN/STUN credentials the SFU hands us on joined.
WatchList
Who we are watching, and whether each is online.
Whois
What a WHOIS said about someone.

Enums§

Change
What changed, for a host that wants to react without diffing the whole model.
Command
Something to do on this connection.
Credentials
What to authenticate with.
E2eeError
Everything that can go wrong here: a doomed handshake, a ratchet that refuses to advance, or a caller asking the state machine for a transition it does not allow.
E2eeRole
Which side of the handshake a session played, once negotiation has started.
Event
Something the host needs to know about.
Frame
One t/v protocol frame, exactly as the wire’s client-only tag carries it (init, accept, reject, ack, close) or, for msg and media, the ?obe2ee:-prefixed body.
MessageKind
What kind of thing happened.
OnOff
The two states an intent frame like mic or hand toggles between.
Phase
How far the connection has got.
PinOutcome
The result of observing a peer’s fingerprint against what was previously pinned for them.
PresenceState
The state a presence notification carries.
Role
Whether a room participant may publish audio and video, or only receive it.
RoomKind
Who may publish in a voice room, decided by the channel’s sigil.
SaslFailure
Why authentication ended without succeeding.
ScramError
Why an exchange could not continue.
SessionState
How far a conversation has got towards being encrypted.
Severity
How serious a standard-replies message is.
Signal
One +obsidianirc/rtc signalling frame.
ToggleKind
Which per-participant toggle a presence notification reports, for its toggle sub-shape.
Typing
Whether we are still composing a message.

Constants§

DEFAULT_CHUNK_BUDGET
Default per-chunk SDP budget, in bytes.
DEFAULT_MAX_CHUNKS_PER_REASSEMBLY
How many chunks one in-flight reassembly may claim before it is refused outright.
DEFAULT_MAX_CONCURRENT_REASSEMBLIES
How many distinct chunked signals may be reassembling at once.
DEFAULT_RETENTION
How many messages one channel or conversation keeps before the oldest are dropped.
E2EE_PROTOCOL_VERSION
The wire’s protocol version, carried as v on every frame. Never varies today; kept as a named constant for whoever writes the wire codec rather than a magic 1 in two places.
MAX_SKIP
One skip-ahead jump’s bound: a single message whose counter implies more than this many unseen messages in one chain is refused outright, rather than buffered.
MAX_SKIPPED_KEYS
The total number of out-of-order message keys this ratchet will hold onto at once, across every chain it has ever had. Beyond this, the oldest key is evicted to make room, so a peer cannot exhaust memory by never sending the messages a lower counter promised.
PRIVILEGED_COMMANDS
Command names a self-registered bot must never be allowed to claim.
WANTED_CAPS
The capabilities this engine knows how to use, in the order we ask for them.

Traits§

RandomSource
A source of random bytes, supplied by the caller.

Functions§

accept_offer
The responder’s reaction to an inbound init: verify the bundle’s self-signature, derive the X3DH secret, and open a sending-only ratchet whose first message (boot) proves it derived the same secret the initiator will.
complete_handshake
The initiator’s reaction to an inbound accept: verify the responder’s signature over its own ephemeral key, derive the X3DH secret, and decrypt boot to complete the receiving side of the ratchet.
create_offer
Build the prekey bundle an init frame carries: a fresh signed-prekey and one-time-prekey, signed together with the identity key by the long-term signing key.
is_privileged
True when this command name may only be claimed by a bot an operator configured.
keeps_own_offer
Decide who keeps their offer when both sides send init at the same moment.
reassemble
Reassemble a complete set of fragments back into the payload they were split from.
split_sdp
Split sdp into chunks of at most budget bytes each, sharing id.