pub struct ControlHandle { /* private fields */ }Expand description
Playback controls for a live connection.
A call returns once the connection has handled it: a transport command has been written to the
server, and a level or mute change has been recorded and included in the next state report. It
is an error when the connection has ended, when no session is established at that moment, and
when the server did not activate the role the command belongs to: transport commands need
controller@v1, volume and mute state need player@v1. A transport command the server did not
list in its controller state is refused as well, so a host can offer exactly the buttons the
server accepts.
Implementations§
Source§impl ControlHandle
impl ControlHandle
Sourcepub async fn set_volume(&self, level: u8) -> Result<u8>
pub async fn set_volume(&self, level: u8) -> Result<u8>
Sets the output level, limited by ClientConfig::volume_policy against the level in
force, and returns the level that was applied.
The level belongs to the connection: the session reports the applied value to the server
with its next state report, which is the initial report when the first clock measurement is
still pending, and every reconnect keeps it. A new connection starts from
ClientConfig::volume, so a host passes the level it restored there and uses this call
for changes after that. ControlHandle::volume answers what is in force without a call.
Sourcepub async fn report_volume(&self, level: u8) -> Result<()>
pub async fn report_volume(&self, level: u8) -> Result<()>
Reports the level the device is actually at, without applying the volume policy.
ControlHandle::set_volume treats its argument as a request, so the policy may lower it
and above the threshold it limits one step. A host that knows the level its output is
really at - because the device applied a level at its own control, or because another
process raised it - reports that level with this call instead: it becomes the level in
force, ControlHandle::volume returns it, and the next client/state carries it
unchanged, so the server’s view matches the output.
The protocol’s range still applies. A level above 100 is refused with an error before anything is recorded or sent; the policy is not consulted and does not clamp the value.
§Errors
Returns an error for a level above 100, for a connection that has ended, and when the
server did not activate player@v1.
Sourcepub async fn set_muted(&self, muted: bool) -> Result<()>
pub async fn set_muted(&self, muted: bool) -> Result<()>
Sets the mute state without changing the level.
The reported level therefore stays what it was, and the server sees the mute in the
muted field alone.
Sourcepub fn volume(&self) -> u8
pub fn volume(&self) -> u8
Returns the volume level in force.
The value follows every change the connection made or received, including a mute, which leaves it untouched. It is available without a call, so a host can render its slider while the connection is reconnecting.
Sourcepub fn pairing_token(&self) -> Option<String>
pub fn pairing_token(&self) -> Option<String>
The version-0 pairing token for this client, or None when no
Storage is configured.
The token is SP:0 plus the base32 body of the identity’s public key and the pairing PSK
that was drawn or restored when the client started, so it is fixed for the client’s
lifetime and survives a reconnect. A token is a credential: anyone holding it can pair a
server with this client, so a host renders it only while the operator needs it and never
writes it into a log.
Sourcepub async fn open_pairing_window(&self) -> Result<()>
pub async fn open_pairing_window(&self) -> Result<()>
Opens a pairing window on the live connection and starts a waiting static-code attempt.
The pairing window is the client’s half of the static code flow’s operator gesture: the host decides what the gesture is - a button press, a pinhole, a power-cycle pattern - and calls this when it happened. The window belongs to the connection that is live now, so it is opened there and closes when that connection ends, when the configured lifetime expires, when a pairing completes, or after five failed key confirmations.
§Errors
Returns an error when no connection is established at this moment. A call that arrives while the client is reconnecting is refused rather than remembered for the next connection, which the spec requires: a window admits attempts only on the connection that carries its gesture.
Sourcepub async fn release_holdback(&self) -> Result<()>
pub async fn release_holdback(&self) -> Result<()>
Releases the dynamic flow’s round limit: the deliberate operator action the spec requires.
After twenty rounds without a verified server_kc, the client aborts the attempt and holds
further dynamic attempts back, answering their activations with client/pair-pending. The
counter is not partitioned by server and only this call - or a verified server_kc - resets
it. A host wires it to whatever gesture means “let this device try pairing again”.
Unlike a pairing window, the release needs no connection: the count belongs to the process, and the next connection starts from a clean one. The call still answers the current level, so it observes the same contract as the other control requests.