Skip to main content

obby_client/
lib.rs

1//! The Obby client engine.
2//!
3//! One [`Client`] is one connection. It owns the registration state machine, the negotiated
4//! capabilities and the client model. It opens no socket, reads no clock and renders nothing: the
5//! host pushes bytes and time in, and drains bytes and events out.
6//!
7//! ```
8//! use obby_client::{Client, Config, Event};
9//!
10//! let mut client = Client::new(Config::new("mynick"));
11//! client.handle_connected();
12//!
13//! // whatever the host wrote is now waiting to go on the wire
14//! let first = client.poll_transmit().expect("registration starts on connect");
15//! assert!(first.starts_with(b"CAP LS 302"));
16//!
17//! client.handle_bytes(b":irc.example.org CAP * LS :sasl multi-prefix\r\n");
18//! client.handle_bytes(b":irc.example.org CAP * ACK :multi-prefix\r\n");
19//! assert!(matches!(client.poll_event(), Some(Event::CapabilitiesAcknowledged { .. })));
20//! ```
21
22#![cfg_attr(not(feature = "std"), no_std)]
23
24extern crate alloc;
25
26mod batch;
27mod caps;
28mod client;
29mod command;
30#[cfg(feature = "e2ee")]
31mod e2ee;
32#[cfg(feature = "obby")]
33mod extensions;
34#[cfg(feature = "obby")]
35mod json;
36mod label;
37mod model;
38mod monitor;
39mod sasl;
40mod scram;
41mod session;
42mod timer;
43#[cfg(feature = "voice")]
44mod voice;
45
46pub use caps::{Capabilities, Capability, WANTED_CAPS};
47pub use client::{Client, Config, Event, Phase, Severity};
48pub use command::{Command, Typing};
49#[cfg(feature = "e2ee")]
50pub use e2ee::{
51    Error as E2eeError, Fingerprint, Frag, Frame, HandshakeResponse, Identity, IdentityPublic,
52    MAX_SKIP, MAX_SKIPPED_KEYS, PROTOCOL_VERSION as E2EE_PROTOCOL_VERSION, PeerTrust, PendingOffer,
53    PinOutcome, PreKeyBundle, RandomSource, Ratchet, RatchetMessage, Role as E2eeRole, Session,
54    SessionState, accept_offer, complete_handshake, create_offer, keeps_own_offer, reassemble,
55};
56#[cfg(feature = "obby")]
57pub use extensions::{
58    Bot, BotCommand, Bots, Commands, Invitation, LinkPreview, PRIVILEGED_COMMANDS, is_privileged,
59};
60pub use model::{
61    Channel, ChatMessage, Conversation, DEFAULT_RETENTION, LocalUser, Membership, MessageKey,
62    MessageKind, MessageLog, Model, Person, Whois,
63};
64pub use monitor::WatchList;
65pub use sasl::{Credentials, SaslFailure};
66pub use scram::{Scram, ScramError};
67pub use session::Change;
68pub use timer::Now;
69#[cfg(feature = "voice")]
70pub use voice::{
71    ChunkMeta, DEFAULT_CHUNK_BUDGET, DEFAULT_MAX_CHUNKS_PER_REASSEMBLY,
72    DEFAULT_MAX_CONCURRENT_REASSEMBLIES, OnOff, Participant, PresenceState, Role, Room, RoomKind,
73    SdpChunk, SdpReassembler, Signal, ToggleKind, TrackHint, TurnCredentials, split_sdp,
74};
75
76pub use obby_proto as proto;