Skip to main content

Group

Struct Group 

Source
pub struct Group {
    pub id: GroupId,
    pub coordinator_id: SpeakerId,
    pub member_ids: Vec<SpeakerId>,
    pub volume: GroupVolumeHandle,
    pub mute: GroupMuteHandle,
    pub volume_changeable: GroupVolumeChangeableHandle,
    /* private fields */
}
Expand description

Group handle with access to coordinator and members

Provides access to group information and member speakers. All speakers are always in a group - a single speaker forms a group of one.

§Example

// Get all groups
for group in system.groups() {
    println!("Group: {} ({} members)", group.id, group.member_count());
     
    if let Some(coordinator) = group.coordinator() {
        println!("  Coordinator: {}", coordinator.name);
    }
     
    for member in group.members() {
        let role = if group.is_coordinator(&member.id) { "coordinator" } else { "member" };
        println!("  - {} ({})", member.name, role);
    }
}

Fields§

§id: GroupId

Unique group identifier

§coordinator_id: SpeakerId

Coordinator speaker ID

§member_ids: Vec<SpeakerId>

All member speaker IDs (including coordinator)

§volume: GroupVolumeHandle

Group volume (0-100)

§mute: GroupMuteHandle

Group mute state

§volume_changeable: GroupVolumeChangeableHandle

Whether group volume can be changed (event-only, no fetch)

Implementations§

Source§

impl Group

Source

pub fn coordinator(&self) -> Option<Speaker>

Get the coordinator speaker

Returns the Speaker handle for the group’s coordinator. Returns None if the coordinator speaker is not found in state.

§Example
if let Some(coordinator) = group.coordinator() {
    println!("Coordinator: {}", coordinator.name);
    // Control playback via coordinator
    let state = coordinator.playback_state.get();
}
Source

pub fn members(&self) -> Vec<Speaker>

Get all member speakers

Returns Speaker handles for all members in the group, including the coordinator. Only returns speakers that are found in state.

§Example
for member in group.members() {
    println!("Member: {} ({})", member.name, member.model_name);
}
Source

pub fn speaker(&self, name: &str) -> Option<Speaker>

Get a member speaker by name

Returns None if no member with that name exists in this group.

§Example
let group = sonos.group("Living Room").unwrap();
if let Some(kitchen) = group.speaker("Kitchen") {
    println!("Kitchen is in the Living Room group");
}
Source

pub fn is_coordinator(&self, speaker_id: &SpeakerId) -> bool

Check if a speaker is the coordinator of this group

§Example
for member in group.members() {
    if group.is_coordinator(&member.id) {
        println!("{} is the coordinator", member.name);
    }
}
Source

pub fn member_count(&self) -> usize

Get the number of members in this group

§Example
println!("Group has {} members", group.member_count());
Source

pub fn is_standalone(&self) -> bool

Check if this is a standalone group (single speaker)

A standalone group contains only one speaker, which is also the coordinator.

§Example
if group.is_standalone() {
    println!("This speaker is not grouped with others");
}
Source

pub fn add_speaker(&self, speaker: &Speaker) -> Result<(), SdkError>

Add a speaker to this group

Sends SetAVTransportURI to the member speaker with x-rincon:{coordinator_id} to join the coordinator’s audio stream. This is the standard Sonos grouping mechanism. After calling this, re-fetch groups via system.groups() to see updated membership.

Source

pub fn remove_speaker(&self, speaker: &Speaker) -> Result<(), SdkError>

Remove a speaker from this group

Sends BecomeCoordinatorOfStandaloneGroup to the member speaker, causing it to leave the group and become standalone. Cannot remove the coordinator.

Source

pub fn dissolve(&self) -> GroupChangeResult

Dissolve this group by removing all non-coordinator members

Attempts to remove every non-coordinator member, even if some fail. Returns a GroupChangeResult showing which speakers were successfully removed and which failed. For standalone groups, returns an empty result.

Source

pub fn set_volume(&self, volume: u16) -> Result<(), SdkError>

Set group volume (0-100)

Updates the state cache to the new GroupVolume on success.

Source

pub fn set_relative_volume( &self, adjustment: i16, ) -> Result<SetRelativeGroupVolumeResponse, SdkError>

Adjust group volume relative to current level

Returns the new absolute volume.

Source

pub fn set_mute(&self, muted: bool) -> Result<(), SdkError>

Set group mute state

Updates the state cache to the new GroupMute value on success.

Source

pub fn snapshot_volume(&self) -> Result<(), SdkError>

Snapshot the current group volume (for later restore)

Trait Implementations§

Source§

impl Clone for Group

Source§

fn clone(&self) -> Group

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Group

§

impl !RefUnwindSafe for Group

§

impl Send for Group

§

impl Sync for Group

§

impl Unpin for Group

§

impl UnsafeUnpin for Group

§

impl !UnwindSafe for Group

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more