Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

An async client for the Subsonic / OpenSubsonic REST API.

Construct via Client::new and optionally customise with the builder methods (Client::with_client_name, Client::with_api_version, Client::with_http_client).

API endpoint methods are provided by the crate::api module and are available as methods on this struct via extension traits.

Implementations§

Source§

impl Client

Source

pub async fn get_bookmarks(&self) -> Result<Vec<Bookmark>, Error>

Source

pub async fn create_bookmark( &self, id: &str, position: i64, comment: Option<&str>, ) -> Result<(), Error>

Source

pub async fn delete_bookmark(&self, id: &str) -> Result<(), Error>

Source

pub async fn get_play_queue(&self) -> Result<PlayQueue, Error>

Get the play queue (current playlist/position saved by a client).

See https://opensubsonic.netlify.app/docs/endpoints/getplayqueue/

Source

pub async fn save_play_queue( &self, ids: &[&str], current: Option<&str>, position: Option<i64>, ) -> Result<(), Error>

Source

pub async fn get_play_queue_by_index(&self) -> Result<PlayQueueByIndex, Error>

Get the play queue by index (OpenSubsonic extension).

See https://opensubsonic.netlify.app/docs/endpoints/getplayqueuebyindex/

Source

pub async fn save_play_queue_by_index( &self, ids: &[&str], current_index: Option<i32>, position: Option<i64>, ) -> Result<(), Error>

Save the play queue by index (OpenSubsonic extension).

See https://opensubsonic.netlify.app/docs/endpoints/saveplayqueuebyindex/

Source§

impl Client

Source

pub async fn get_music_folders(&self) -> Result<Vec<MusicFolder>, Error>

Source

pub async fn get_indexes( &self, music_folder_id: Option<&str>, if_modified_since: Option<i64>, ) -> Result<Indexes, Error>

Get an indexed structure of all artists (folder-based).

See https://opensubsonic.netlify.app/docs/endpoints/getindexes/

Source

pub async fn get_music_directory(&self, id: &str) -> Result<Directory, Error>

Get a directory listing (folder-based browsing).

See https://opensubsonic.netlify.app/docs/endpoints/getmusicdirectory/

Source

pub async fn get_genres(&self) -> Result<Vec<Genre>, Error>

Source

pub async fn get_artists( &self, music_folder_id: Option<&str>, ) -> Result<ArtistsId3, Error>

Source

pub async fn get_artist(&self, id: &str) -> Result<ArtistWithAlbumsId3, Error>

Get details for an artist, including a list of albums (ID3-based).

See https://opensubsonic.netlify.app/docs/endpoints/getartist/

Source

pub async fn get_album(&self, id: &str) -> Result<AlbumWithSongsId3, Error>

Get details for an album, including a list of songs (ID3-based).

See https://opensubsonic.netlify.app/docs/endpoints/getalbum/

Source

pub async fn get_song(&self, id: &str) -> Result<Child, Error>

Source

pub async fn get_videos(&self) -> Result<Vec<Child>, Error>

Get all video files. Returns an empty list if the server has no videos.

See https://opensubsonic.netlify.app/docs/endpoints/getvideos/

Source

pub async fn get_artist_info( &self, id: &str, count: Option<i32>, include_not_present: Option<bool>, ) -> Result<ArtistInfo, Error>

Source

pub async fn get_artist_info2( &self, id: &str, count: Option<i32>, include_not_present: Option<bool>, ) -> Result<ArtistInfo2, Error>

Source

pub async fn get_album_info(&self, id: &str) -> Result<AlbumInfo, Error>

Get album info (external metadata).

See https://opensubsonic.netlify.app/docs/endpoints/getalbuminfo/

Source

pub async fn get_album_info2(&self, id: &str) -> Result<AlbumInfo, Error>

Source

pub async fn get_similar_songs( &self, id: &str, count: Option<i32>, ) -> Result<Vec<Child>, Error>

Source

pub async fn get_similar_songs2( &self, id: &str, count: Option<i32>, ) -> Result<Vec<Child>, Error>

Source

pub async fn get_top_songs( &self, artist: &str, count: Option<i32>, ) -> Result<Vec<Child>, Error>

Source§

impl Client

Source§

impl Client

Source

pub async fn get_internet_radio_stations( &self, ) -> Result<Vec<InternetRadioStation>, Error>

Source

pub async fn create_internet_radio_station( &self, stream_url: &str, name: &str, home_page_url: Option<&str>, ) -> Result<(), Error>

Source

pub async fn update_internet_radio_station( &self, id: &str, stream_url: &str, name: &str, home_page_url: Option<&str>, ) -> Result<(), Error>

Source

pub async fn delete_internet_radio_station(&self, id: &str) -> Result<(), Error>

Source§

impl Client

Source

pub async fn jukebox_control( &self, action: JukeboxAction, index: Option<i32>, offset: Option<i32>, ids: &[&str], gain: Option<f64>, ) -> Result<JukeboxResult, Error>

Control the jukebox (server-side playback).

See https://opensubsonic.netlify.app/docs/endpoints/jukeboxcontrol/

Source§

impl Client

Source

pub async fn get_album_list( &self, list_type: AlbumListType, size: Option<i32>, offset: Option<i32>, from_year: Option<i32>, to_year: Option<i32>, genre: Option<&str>, music_folder_id: Option<&str>, ) -> Result<Vec<Child>, Error>

Get a list of albums (folder-based).

See https://opensubsonic.netlify.app/docs/endpoints/getalbumlist/

Source

pub async fn get_album_list2( &self, list_type: AlbumListType, size: Option<i32>, offset: Option<i32>, from_year: Option<i32>, to_year: Option<i32>, genre: Option<&str>, music_folder_id: Option<&str>, ) -> Result<Vec<AlbumId3>, Error>

Source

pub async fn get_random_songs( &self, size: Option<i32>, genre: Option<&str>, from_year: Option<i32>, to_year: Option<i32>, music_folder_id: Option<&str>, ) -> Result<Vec<Child>, Error>

Source

pub async fn get_songs_by_genre( &self, genre: &str, count: Option<i32>, offset: Option<i32>, music_folder_id: Option<&str>, ) -> Result<Vec<Child>, Error>

Source

pub async fn get_now_playing(&self) -> Result<Vec<NowPlayingEntry>, Error>

Get what is currently being played by all users.

See https://opensubsonic.netlify.app/docs/endpoints/getnowplaying/

Source

pub async fn get_starred( &self, music_folder_id: Option<&str>, ) -> Result<StarredContent, Error>

Get starred songs, albums and artists (folder-based).

See https://opensubsonic.netlify.app/docs/endpoints/getstarred/

Source

pub async fn get_starred2( &self, music_folder_id: Option<&str>, ) -> Result<Starred2Content, Error>

Get starred songs, albums and artists (ID3-based).

See https://opensubsonic.netlify.app/docs/endpoints/getstarred2/

Source§

impl Client

Source

pub async fn star( &self, ids: &[&str], album_ids: &[&str], artist_ids: &[&str], ) -> Result<(), Error>

Star songs, albums, or artists.

See https://opensubsonic.netlify.app/docs/endpoints/star/

Source

pub async fn unstar( &self, ids: &[&str], album_ids: &[&str], artist_ids: &[&str], ) -> Result<(), Error>

Unstar songs, albums, or artists.

See https://opensubsonic.netlify.app/docs/endpoints/unstar/

Source

pub async fn set_rating(&self, id: &str, rating: i32) -> Result<(), Error>

Set the rating of a song, album, or artist.

A rating of 0 removes the rating.

See https://opensubsonic.netlify.app/docs/endpoints/setrating/

Source

pub async fn scrobble( &self, id: &str, time: Option<i64>, submission: Option<bool>, ) -> Result<(), Error>

Register a song as played (scrobble).

If submission is false, this is a “now playing” notification rather than a scrobble.

See https://opensubsonic.netlify.app/docs/endpoints/scrobble/

Source

pub async fn report_playback( &self, media_id: &str, media_type: &str, position_ms: i64, state: &str, playback_rate: Option<f64>, ignore_scrobble: Option<bool>, ) -> Result<(), Error>

Report playback state to the server (OpenSubsonic, playbackReport extension).

See https://opensubsonic.netlify.app/docs/endpoints/reportplayback/

Source§

impl Client

Source

pub async fn stream( &self, id: &str, max_bit_rate: Option<i32>, format: Option<&str>, time_offset: Option<i32>, estimated_content_length: Option<bool>, ) -> Result<Bytes, Error>

Stream a song or video. Returns the raw bytes.

See https://opensubsonic.netlify.app/docs/endpoints/stream/

Source

pub fn stream_url( &self, id: &str, max_bit_rate: Option<i32>, format: Option<&str>, ) -> Result<Url, Error>

Build a streaming URL for a song without making an HTTP request.

Useful for passing to external audio players or download managers.

Source

pub async fn download(&self, id: &str) -> Result<Bytes, Error>

Download a song or video. Returns raw bytes.

See https://opensubsonic.netlify.app/docs/endpoints/download/

Source

pub fn hls_url( &self, id: &str, bit_rate: Option<&str>, audio_track: Option<&str>, ) -> Result<Url, Error>

Get an HLS playlist URL for a video or song.

See https://opensubsonic.netlify.app/docs/endpoints/hls/

Source

pub async fn get_captions( &self, id: &str, format: Option<&str>, ) -> Result<Bytes, Error>

Get captions (subtitles) for a video. Returns raw bytes.

See https://opensubsonic.netlify.app/docs/endpoints/getcaptions/

Source

pub async fn get_cover_art( &self, id: &str, size: Option<i32>, ) -> Result<Bytes, Error>

Get cover art for an album or artist. Returns raw image bytes.

See https://opensubsonic.netlify.app/docs/endpoints/getcoverart/

Source

pub fn cover_art_url(&self, id: &str, size: Option<i32>) -> Result<Url, Error>

Build a cover art URL without making an HTTP request.

Source

pub async fn get_lyrics( &self, artist: Option<&str>, title: Option<&str>, ) -> Result<Lyrics, Error>

Get lyrics for a song (legacy, unstructured).

See https://opensubsonic.netlify.app/docs/endpoints/getlyrics/

Source

pub async fn get_lyrics_by_song_id( &self, id: &str, enhanced: Option<bool>, ) -> Result<LyricsList, Error>

Get structured lyrics for a song by ID (OpenSubsonic extension).

See https://opensubsonic.netlify.app/docs/endpoints/getlyricsbysongid/

Source

pub async fn get_avatar(&self, username: &str) -> Result<Bytes, Error>

Get a user’s avatar image. Returns raw image bytes.

See https://opensubsonic.netlify.app/docs/endpoints/getavatar/

Source§

impl Client

Source

pub async fn get_playlists( &self, username: Option<&str>, ) -> Result<Vec<Playlist>, Error>

Source

pub async fn get_playlist(&self, id: &str) -> Result<PlaylistWithSongs, Error>

Source

pub async fn create_playlist( &self, playlist_id: Option<&str>, name: Option<&str>, song_ids: &[&str], ) -> Result<PlaylistWithSongs, Error>

Create or update a playlist.

If playlist_id is provided, the existing playlist is updated. Otherwise, a new playlist is created with the given name.

See https://opensubsonic.netlify.app/docs/endpoints/createplaylist/

Source

pub async fn update_playlist( &self, playlist_id: &str, name: Option<&str>, comment: Option<&str>, public: Option<bool>, song_ids_to_add: &[&str], song_indexes_to_remove: &[i32], ) -> Result<(), Error>

Update a playlist (name, comment, public status, add/remove songs).

See https://opensubsonic.netlify.app/docs/endpoints/updateplaylist/

Source

pub async fn delete_playlist(&self, id: &str) -> Result<(), Error>

Source§

impl Client

Source

pub async fn get_podcasts( &self, include_episodes: Option<bool>, id: Option<&str>, ) -> Result<Vec<PodcastChannel>, Error>

Get all podcast channels.

If include_episodes is false, episodes are not included in the response.

See https://opensubsonic.netlify.app/docs/endpoints/getpodcasts/

Source

pub async fn get_newest_podcasts( &self, count: Option<i32>, ) -> Result<Vec<PodcastEpisode>, Error>

Source

pub async fn get_podcast_episode( &self, id: &str, ) -> Result<PodcastEpisode, Error>

Get a specific podcast episode (OpenSubsonic extension).

See https://opensubsonic.netlify.app/docs/endpoints/getpodcastepisode/

Source

pub async fn refresh_podcasts(&self) -> Result<(), Error>

Tell the server to check for new podcast episodes.

See https://opensubsonic.netlify.app/docs/endpoints/refreshpodcasts/

Source

pub async fn create_podcast_channel(&self, url: &str) -> Result<(), Error>

Add a new podcast channel (by feed URL).

See https://opensubsonic.netlify.app/docs/endpoints/createpodcastchannel/

Source

pub async fn delete_podcast_channel(&self, id: &str) -> Result<(), Error>

Source

pub async fn delete_podcast_episode(&self, id: &str) -> Result<(), Error>

Source

pub async fn download_podcast_episode(&self, id: &str) -> Result<(), Error>

Tell the server to download a podcast episode.

See https://opensubsonic.netlify.app/docs/endpoints/downloadpodcastepisode/

Source§

impl Client

Source§

impl Client

Source

pub async fn search( &self, artist: Option<&str>, album: Option<&str>, title: Option<&str>, any: Option<&str>, count: Option<i32>, offset: Option<i32>, newer_than: Option<i64>, ) -> Result<SearchResult, Error>

Source

pub async fn search2( &self, query: &str, artist_count: Option<i32>, artist_offset: Option<i32>, album_count: Option<i32>, album_offset: Option<i32>, song_count: Option<i32>, song_offset: Option<i32>, music_folder_id: Option<&str>, ) -> Result<SearchResult2, Error>

Source

pub async fn search3( &self, query: &str, artist_count: Option<i32>, artist_offset: Option<i32>, album_count: Option<i32>, album_offset: Option<i32>, song_count: Option<i32>, song_offset: Option<i32>, music_folder_id: Option<&str>, ) -> Result<SearchResult3, Error>

Source§

impl Client

Source

pub async fn get_shares(&self) -> Result<Vec<Share>, Error>

Source

pub async fn create_share( &self, ids: &[&str], description: Option<&str>, expires: Option<i64>, ) -> Result<Vec<Share>, Error>

Source

pub async fn update_share( &self, id: &str, description: Option<&str>, expires: Option<i64>, ) -> Result<(), Error>

Source

pub async fn delete_share(&self, id: &str) -> Result<(), Error>

Source§

impl Client

Source

pub async fn get_sonic_similar_tracks( &self, id: &str, count: Option<i32>, ) -> Result<Vec<SonicMatch>, Error>

Get tracks sonically similar to the given song (OpenSubsonic, sonicSimilarity extension).

See https://opensubsonic.netlify.app/docs/endpoints/getsonicsimilartracks/

Source

pub async fn find_sonic_path( &self, start_song_id: &str, end_song_id: &str, count: Option<i32>, ) -> Result<Vec<SonicMatch>, Error>

Find a path of sonically similar tracks between two songs (OpenSubsonic, sonicSimilarity extension).

See https://opensubsonic.netlify.app/docs/endpoints/findsonicpath/

Source§

impl Client

Source

pub async fn ping(&self) -> Result<(), Error>

Test connectivity with the server. Returns Ok(()) on success.

See https://opensubsonic.netlify.app/docs/endpoints/ping/

Source

pub async fn get_license(&self) -> Result<License, Error>

Get details about the software license.

See https://opensubsonic.netlify.app/docs/endpoints/getlicense/

Source

pub async fn get_open_subsonic_extensions( &self, ) -> Result<Vec<OpenSubsonicExtension>, Error>

Get the list of OpenSubsonic API extensions supported by the server.

See https://opensubsonic.netlify.app/docs/endpoints/getopensubsonicextensions/

Source

pub async fn token_info(&self) -> Result<TokenInfo, Error>

Get information about the API token (OpenSubsonic extension).

See https://opensubsonic.netlify.app/docs/endpoints/tokeninfo/

Source§

impl Client

Source

pub async fn get_transcode_decision( &self, id: &str, max_bit_rate: Option<i32>, format: Option<&str>, client_info: Option<&ClientInfo>, ) -> Result<TranscodeDecision, Error>

Get a transcode decision for a song (OpenSubsonic extension).

This endpoint uses POST with a JSON body containing client info.

See https://opensubsonic.netlify.app/docs/endpoints/gettranscodedecision/

Source

pub fn get_transcode_stream_url( &self, id: &str, max_bit_rate: Option<i32>, format: Option<&str>, ) -> Result<Url, Error>

Get a transcoded stream URL (OpenSubsonic extension).

Returns the URL for streaming transcoded audio. Does not make an HTTP request.

See https://opensubsonic.netlify.app/docs/endpoints/gettranscodestream/

Source

pub async fn get_transcode_stream( &self, id: &str, max_bit_rate: Option<i32>, format: Option<&str>, ) -> Result<Bytes, Error>

Get a transcoded stream as raw bytes (OpenSubsonic extension).

See https://opensubsonic.netlify.app/docs/endpoints/gettranscodestream/

Source§

impl Client

Source

pub async fn get_user(&self, username: &str) -> Result<User, Error>

Get details about a specific user.

See https://opensubsonic.netlify.app/docs/endpoints/getuser/

Source

pub async fn get_users(&self) -> Result<Vec<User>, Error>

Get details about all users (admin only).

See https://opensubsonic.netlify.app/docs/endpoints/getusers/

Source

pub async fn create_user( &self, username: &str, password: &str, email: &str, ldap_authenticated: Option<bool>, admin_role: Option<bool>, settings_role: Option<bool>, stream_role: Option<bool>, jukebox_role: Option<bool>, download_role: Option<bool>, upload_role: Option<bool>, playlist_role: Option<bool>, cover_art_role: Option<bool>, comment_role: Option<bool>, podcast_role: Option<bool>, share_role: Option<bool>, video_conversion_role: Option<bool>, music_folder_ids: &[i64], ) -> Result<(), Error>

Source

pub async fn update_user( &self, username: &str, password: Option<&str>, email: Option<&str>, ldap_authenticated: Option<bool>, admin_role: Option<bool>, settings_role: Option<bool>, stream_role: Option<bool>, jukebox_role: Option<bool>, download_role: Option<bool>, upload_role: Option<bool>, playlist_role: Option<bool>, cover_art_role: Option<bool>, comment_role: Option<bool>, podcast_role: Option<bool>, share_role: Option<bool>, video_conversion_role: Option<bool>, max_bit_rate: Option<i32>, music_folder_ids: &[i64], ) -> Result<(), Error>

Update an existing user (admin only).

See https://opensubsonic.netlify.app/docs/endpoints/updateuser/

Source

pub async fn delete_user(&self, username: &str) -> Result<(), Error>

Source

pub async fn change_password( &self, username: &str, password: &str, ) -> Result<(), Error>

Source§

impl Client

Source

pub fn new(base_url: &str, auth: Auth) -> Result<Self, Error>

Create a new Subsonic API client.

§Arguments
§Errors

Returns Error::Url if base_url cannot be parsed.

Source

pub fn with_client_name(self, name: &str) -> Self

Override the client application name sent as the c parameter.

Source

pub fn with_api_version(self, version: &str) -> Self

Override the Subsonic REST protocol version sent as the v parameter.

Source

pub fn with_http_client(self, client: Client) -> Self

Inject a custom reqwest::Client (e.g. with custom timeouts or TLS settings).

Source

pub fn with_danger_accept_invalid_certs(self) -> Result<Self, Error>

Accept invalid TLS certificates (self-signed, expired, wrong hostname).

WARNING: This disables TLS certificate verification and should only be used in trusted network environments (e.g. Tailscale, local LAN).

§Errors

Returns Error::Http if the HTTP client cannot be built.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

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

impl Debug for Client

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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