Struct sunk::Client

source ·
pub struct Client {
    pub ver: Version,
    pub target_ver: Version,
    /* private fields */
}
Expand description

A client to make requests to a Subsonic instance.

The Client holds an internal connection pool and stores authentication details. It is highly recommended to re-use a Client where possible rather than creating a new one each time it is required.

Examples

Basic usage:

use sunk::Client;

let client = Client::new(site, user, password)?;
client.ping()?;

Notes

Generally, any method that requires a response from a Subsonic server will require a Client . Any method that issues a request will have the possiblity to return an error. A request will result in an error if any of the following occurs:

  • the Client is built with an unrecognised URL
  • connecting to the Subsonic server fails
  • the Subsonic server returns an API error

Fields

ver: Version

Version that the Client supports.

target_ver: Version

Version that the Client is targeting; currently only has an effect on the authentication method.

Implementations

Constructs a client to interact with a Subsonic instance.

Adjusts the client to target a specific version.

By default, the client will target version 1.14.0, as built by sunk. However, this means that any servers that don’t implement advanced features that sunk does automatically, such as token-based authentication, will be incompatible. The target version allows setting an override on these features by making the client limit itself to features that the target will support.

Note that (currently) the client does not provide any sanity-checking on which methods are called; attempting to access an endpoint not supported by the server will fail after the call, not before.

Returns the raw bytes of a HLS slice.

Tests a connection with the server.

Get details about the software license. Note that access to the REST API requires that the server has a valid license (after a 30-day trial period). To get a license key you must upgrade to Subsonic Premium.

Forks of Subsonic (Libresonic, Airsonic, etc.) do not require licenses; this method will always return a valid license and trial when attempting to connect to these services.

Initiates a rescan of the media libraries.

Note

This method was introduced in version 1.15.0. It will not be supported on servers with earlier versions of the Subsonic API.

Gets the status of a scan. Returns the current status for media library scanning.

Note

This method was introduced in version 1.15.0. It will not be supported on servers with earlier versions of the Subsonic API.

Returns all configured top-level music folders.

Returns all genres.

Returns all currently playing media on the server.

Searches for lyrics matching the artist and title. Returns None if no lyrics are found.

Returns albums, artists and songs matching the given search criteria. Supports paging through the result. See the search module for documentation.

Examples

Basic usage:

use sunk::search::{self, SearchPage};
use sunk::Client;

let client = Client::new(site, user, password)?;

let search_size = SearchPage::new();
let ignore = search::NONE;

let result = client.search("smile", ignore, ignore, search_size)?;

assert!(result.artists.is_empty());
assert!(result.albums.is_empty());
assert!(!result.songs.is_empty());

Returns a list of all starred artists, albums, and songs.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.