Skip to main content

ControlHandle

Struct ControlHandle 

Source
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

Source

pub async fn play(&self) -> Result<()>

Resumes playback.

Source

pub async fn pause(&self) -> Result<()>

Pauses playback at the current position.

Source

pub async fn next(&self) -> Result<()>

Skips to the next track.

Source

pub async fn previous(&self) -> Result<()>

Skips to the previous track.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for ControlHandle

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ControlHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.