Expand description
§Sonos SDK - Sync-First API for Sonos Control
Provides a clean, property-centric API for controlling Sonos devices. All operations are synchronous - no async/await required.
§Quick Start
ⓘ
use sonos_sdk::prelude::*;
fn main() -> Result<(), SdkError> {
let sonos = SonosSystem::new()?;
// Direct SOAP calls — no event infrastructure created
let kitchen = sonos.speaker("Kitchen").unwrap();
kitchen.play()?;
let vol = kitchen.volume.fetch()?;
// Fluent navigation
let group = kitchen.group().unwrap();
println!("Kitchen is in group {}", group.id);
// ONLY NOW does the event manager lazily initialize
let _vol = kitchen.volume.watch()?;
for event in sonos.iter() {
println!("Changed: {} on {}", event.property_key, event.speaker_id);
}
Ok(())
}§Key Features
- Sync-First API: All methods are synchronous - no async/await required
- Cheap constructor:
SonosSystem::new()does discovery only — event infrastructure is lazy - DOM-like API: Access properties directly on speaker objects
- Three access patterns:
get()for cached,fetch()for fresh,watch()for reactive - Fluent navigation:
speaker.group(),group.speaker("name") - Type safety: All properties are strongly typed
- Resource efficiency: Shared state management and HTTP connections
§Available Properties
Currently implemented:
volume- Speaker volume (0-100)playback_state- Current playback state (Playing/Paused/Stopped/Transitioning)mute- Mute statebass,treble,loudness- EQ settingsposition- Current track positioncurrent_track- Track metadata
§Architecture
sonos-sdk (Sync-First DOM-like API)
↓
sonos-state (State Management) ←→ sonos-event-manager (Event Subscriptions)
↓ ↓
sonos-api (UPnP Operations) sonos-stream (Event Processing)Re-exports§
pub use property::PropertyHandle;pub use property::SpeakerContext;pub use property::WatchHandle;pub use property::WatchMode;pub use property::GroupContext;pub use property::GroupFetchable;pub use property::GroupMuteHandle;pub use property::GroupPropertyHandle;pub use property::GroupVolumeChangeableHandle;pub use property::GroupVolumeHandle;
Modules§
- prelude
- Convenience re-exports for common types.
- property
- Property handles for DOM-like property access
Structs§
- AddURI
ToQueue Response - Become
Coordinator OfStandalone Group Response - Change
Event - A change event emitted when a watched property changes
- Change
Iterator - Blocking iterator over property change events
- Create
Saved Queue Response - GetCrossfade
Mode Response - GetCurrent
Transport Actions Response - GetDevice
Capabilities Response - GetMedia
Info Response - GetRemaining
Sleep Timer Duration Response - GetRunning
Alarm Properties Response - GetTransport
Settings Response - Group
- Group handle with access to coordinator and members
- Group
Change Result - Result of a multi-speaker group operation (e.g.,
dissolve(),create_group()) - GroupId
- Unique identifier for a zone group
- Group
Mute - Group master mute state
- Group
Volume - Group master volume level (0-100)
- Group
Volume Changeable - Whether the group volume can be changed
- Remove
Track Range From Queue Response - Save
Queue Response - SetRelative
Group Volume Response - SetRelative
Volume Response - Sonos
System - Main system entry point - provides DOM-like API
- Speaker
- Speaker handle with property access
- Speaker
Id - Unique identifier for a Sonos speaker
- Volume
- Master volume level (0-100)
Enums§
- Play
Mode - Play mode for the
set_play_mode()method - Playback
State - Current playback state
- SdkError
- Seek
Target - Seek target for the
seek()method