pub struct ClientConfig {Show 19 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 strict_group_id: bool,
pub unpaired_access: bool,
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>,
pub inbound: Option<Inbound>,
}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.
strict_group_id: boolWhether a group_id outside the spec’s 43 base64url characters closes the connection.
The spec makes such a value a protocol error, and with true the client behaves that way:
the attempt ends and Event::Disconnected reports why.
The default is false. A non-canonical but well-formed identifier - non-empty, at most 128
bytes, valid UTF-8 without control characters - is then accepted as an opaque string and
reported once per connection as Event::GroupIdNotCanonical.
That tolerance exists because a real server sends a UUID instead; see
docs/spec-deviations.md. A host that talks to a conformant server, or that wants the
spec’s rule enforced, sets this to true.
unpaired_access: boolWhether this client admits a server with no pairing record.
The value is advertised in client/hello as unpaired_access.enabled and both sides act on
it. With false this client refuses to activate a session that is not keyed by a long-term
PSK for playback: such a server/activate ends the connection with client/goodbye reason
pairing_required. A server that honours the advertisement grants no roles to an unpaired
client whose hello says false. Pairing is unaffected: both pairing flows run over a
Sentinel-keyed session and stay admissible.
pairing.md leaves the default to the manufacturer and recommends false for a client whose
input a stranger could reach, such as a microphone. The default here is true, which is what
every release before this setting did.
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.
inbound: Option<Inbound>The server-initiated half of the connection mode, or None for client-initiated
connections.
Setting it makes advertise publish _sendspin._tcp and accept the
servers that connect, and makes a manual connect fail: connection.md
lets a client use one of the two methods at a time, never both. Inbound::new fills the
listen address and the path with the values the spec recommends.
Implementations§
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn new(
server: impl Into<String>,
player_name: impl Into<String>,
identity: Identity,
) -> ClientConfig
pub fn new( server: impl Into<String>, player_name: impl Into<String>, identity: Identity, ) -> ClientConfig
Builds a configuration for server with the crate’s defaults.
Everything a host rarely changes starts at a documented value: no device description, no
pairing store, AudioMode::Decode, volume 100 and unmuted, VolumePolicy::default,
DEFAULT_MAX_BACKOFF, the tolerated foreign group_id, unpaired access admitted, and
DEFAULT_PAIRING_TIMEOUT. A
host that restores a level or a mute state sets ClientConfig::volume and
ClientConfig::muted on the value this returns.
The fields stay public, so a host can also build the struct itself and name every field.
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.