pub struct ClientConfig {Show 16 fields
pub server: String,
pub player_name: String,
pub device_info: Option<DeviceInfo>,
pub identity: Identity,
pub storage: Option<Arc<dyn Storage>>,
pub audio_mode: AudioMode,
pub volume: u8,
pub muted: bool,
pub volume_policy: VolumePolicy,
pub max_backoff: Duration,
pub pairing_timeout: Duration,
pub static_pairing_code: Option<String>,
pub pairing_window: Duration,
pub pairing_pending_text: Option<String>,
pub code_formats: Vec<CodeFormat>,
pub code_out_channels: Vec<CodeOutChannel>,
}Expand description
Everything the client needs to open a session.
The identity is the client’s long-lived X25519 keypair. It also becomes the client_id the
server sees, so reusing it keeps the player recognisable across reconnects; the crate never
generates or replaces one on its own.
Fields§
§server: StringServer address as host:port, or a full ws:// URL.
A bare address connects to ws://<server>/sendspin. TLS is not part of this build, so a
wss:// URL is rejected rather than silently downgraded.
player_name: StringFriendly name announced to the server, non-empty and at most MAX_PLAYER_NAME_LEN bytes.
device_info: Option<DeviceInfo>Description of the device the client runs on, announced in client/hello.
The server displays it to the operator. A host that does not know the hardware passes
None and no device_info object is sent, so the server shows only the player name.
identity: IdentityLong-lived keypair that identifies this client.
Restore a stored keypair with Identity::from_secret_base64; generating a fresh one
makes the server treat the player as a new device.
storage: Option<Arc<dyn Storage>>Where the pairing PSK and the pairing records live, or None for a guest-only client.
The host owns the store; see Storage. With a store the client offers the Pairing PSK
method, keeps one pairing PSK across restarts and writes a record for every completed
pairing. Without one it offers no pairing method at all: it never draws a key it cannot
hand back, and it answers a pairing activation with pair/abort reason
method_not_supported. A plain guest session is unchanged either way.
audio_mode: AudioModeWhether the sink receives samples or encoded frames.
volume: u8Output level to start from, in the protocol’s 0-100 range.
The session reports this level in its first client/state and applies the volume limit
against it, so a host passes the level it restored instead of an invented one. A host
without a stored level passes 100, which neither attenuates nor limits an incoming request.
muted: boolMute state to start from.
Reported in the first client/state; a host without a stored state passes false.
volume_policy: VolumePolicyLimits applied to every volume request.
The session applies the policy to a command from the server and to a level the host sets
through ControlHandle::set_volume; the value it
reports back is always the applied one. VolumePolicy::default keeps the fixed rule of
earlier releases.
max_backoff: DurationUpper bound for the delay between reconnects.
The connection reports a recommended delay in
Event::Disconnected and waits it before the next attempt;
next_backoff never returns more than this.
pairing_timeout: DurationHow long one pairing attempt may run, measured from client/pair-init.
On expiry the client sends pair/abort with reason attempt_timeout and reports
Event::PairingFailed. The protocol recommends two minutes,
which is DEFAULT_PAIRING_TIMEOUT; a host shortens it
only for tests or for a deployment that wants a tighter bound.
static_pairing_code: Option<String>The operator-facing static pairing code, exactly eight decimal digits.
The code is configuration, never generated: a manufacturer provisions one per device, and
the operator reads it off the device or its leaflet. Offering the static code method in
client/hello depends on this field being set, so a client without a code never advertises
a method it cannot complete.
The code is a credential: anyone who knows it and can reach the server may pair. It is
never formatted - ClientConfig’s Debug prints it redacted - and never logged.
pairing_window: DurationHow long an operator-opened pairing window admits attempts, recommended five minutes.
The window runs from ControlHandle::open_pairing_window
and does not pause during an attempt. On expiry it closes silently; an attempt already in
progress runs to its own end.
pairing_pending_text: Option<String>Sentence sent in client/pair-pending, in the host’s language.
A host that wants to tell the operator what to do sets it here; without one the message is sent with no text, because the crate does not invent operator-facing prose.
code_formats: Vec<CodeFormat>Emission formats the client offers for a dynamic pairing code.
An empty list offers no dynamic method at all; a non-empty one advertises
dynamic_pairing_code in client/hello, together with ClientConfig::code_out_channels.
Both lists must be set for the method to be offered, because the protocol treats a
descriptor left without a known format or channel as unrecognized. The code itself is
derived per attempt, never configured.
code_out_channels: Vec<CodeOutChannel>Channels the host can carry a dynamic pairing code through.
The host sets what it can render or speak; the server picks the method’s format, and the
client emits the code through Event::PairingCode.
Trait Implementations§
Source§impl Clone for ClientConfig
impl Clone for ClientConfig
Source§impl Debug for ClientConfig
impl Debug for ClientConfig
Source§fn fmt(&self, formatter: &mut Formatter<'_>) -> Result
fn fmt(&self, formatter: &mut Formatter<'_>) -> Result
Formats the configuration without the store and without key material.
The store holds the pairing PSK and the records, and its own Debug is the host’s; the
identity redacts its secret. Neither is delegated to here, so a Debug log of a
configuration cannot leak a key.