[][src]Crate sonor

This crate is a Sonos controller library written in Rust. It operates asynchronously and aims for a simple to use yet powerful API.

Example

let speaker = sonor::find("your room name", Duration::from_secs(2)).await?
    .expect("room exists");

println!("The volume is currently at {}", speaker.volume().await?);

match speaker.track().await? {
    Some(track_info) => println!("- Currently playing '{}", track_info.track()),
    None => println!("- No track currently playing"),
}

speaker.clear_queue().await?;

speaker.join("some other room").await?;

For a full list of actions implemented, look at the Speaker docs.

If your use case isn't covered, this crate also exposes the raw UPnP Action API here. It can be used like this:

use sonor::URN;

let service = URN::service("schemas-upnp-org", "GroupRenderingControl", 1);
let args = "<InstanceID>0</InstanceID>";
let response = speaker.action(&service, "GetGroupMute", args).await?;

println!("{}", response["CurrentMute"]);

Re-exports

pub use rupnp;

Structs

Snapshot

A Snapshot of the state the speaker is in right now. Useful for announcing some clip at a lower volume, then later resume where you left off. The struct is obtained by calling the snapshot-method on a speaker and applied using Speaker::apply.

Speaker

A sonos speaker, wrapping a UPnP-Device and providing user-oriented methods in an asynyronous API.

SpeakerInfo

A more lightweight representation of a speaker containing only the name, uuid and location. It gets returned by the zone_group_state function.

Track

The track struct contains information about the music in UPnP music players. It always has a title and an URI, but sometimes there is a creator, album or duration specified too.

TrackInfo

A Track with some metadata like the track number, its duration and the elapsed time.

Enums

Error

The UPnP Error type.

RepeatMode

This enum describes how Sonos repeats the current playlist.

URN

Uniform Resource Name

Functions

discover

Discover sonos players on the network.

find

Search for a sonos speaker by its name.