pub struct SubsonicClient { /* private fields */ }Expand description
Subsonic/Navidrome API client.
Holds two HTTP clients with different timeout semantics: http bounds a
whole JSON request, which is right for small API responses read in one go;
downloader bounds only connect and per-read stalls, so a large track on a
slow link is never cut off for taking too long overall.
Implementations§
Source§impl SubsonicClient
impl SubsonicClient
pub fn new(base_url: &str, username: &str, password: &str) -> Self
pub fn from_auth(auth: SubsonicAuth) -> Self
Sourcepub fn get_cover_art(
&self,
id: &str,
size: Option<u32>,
) -> Result<Vec<u8>, SubsonicError>
pub fn get_cover_art( &self, id: &str, size: Option<u32>, ) -> Result<Vec<u8>, SubsonicError>
Fetch cover art bytes for a song or album ID.
Returns the raw image rather than a parsed response — getCoverArt
answers with image data, not JSON, so it can’t go through get().
size requests a square thumbnail; omit it for the original.
Sourcepub fn ping(&self) -> Result<(), SubsonicError>
pub fn ping(&self) -> Result<(), SubsonicError>
Ping the server — verify connection and credentials.
Sourcepub fn get_artists(&self) -> Result<Vec<SubsonicArtist>, SubsonicError>
pub fn get_artists(&self) -> Result<Vec<SubsonicArtist>, SubsonicError>
Get all artists (indexed).
Sourcepub fn get_album(&self, id: &str) -> Result<SubsonicAlbumFull, SubsonicError>
pub fn get_album(&self, id: &str) -> Result<SubsonicAlbumFull, SubsonicError>
Get an album by ID, including its tracks.
Sourcepub fn get_album_list(
&self,
list_type: &str,
size: u32,
offset: u32,
) -> Result<Vec<SubsonicAlbum>, SubsonicError>
pub fn get_album_list( &self, list_type: &str, size: u32, offset: u32, ) -> Result<Vec<SubsonicAlbum>, SubsonicError>
Get a paginated list of albums.
Sourcepub fn stream_url(&self, track_id: &str) -> Result<String, SubsonicError>
pub fn stream_url(&self, track_id: &str) -> Result<String, SubsonicError>
Build the streaming URL for a track (doesn’t make a request).
Sourcepub fn stream_url_template(&self, track_id: &str) -> String
pub fn stream_url_template(&self, track_id: &str) -> String
Stream URL without auth params — safe for database storage.
Sourcepub fn download(&self, track_id: &str, dest: &Path) -> Result<(), SubsonicError>
pub fn download(&self, track_id: &str, dest: &Path) -> Result<(), SubsonicError>
Download a track to a local path.
Sourcepub fn download_with_progress(
&self,
track_id: &str,
dest: &Path,
on_progress: impl Fn(u64, u64),
) -> Result<(), SubsonicError>
pub fn download_with_progress( &self, track_id: &str, dest: &Path, on_progress: impl Fn(u64, u64), ) -> Result<(), SubsonicError>
Download a track with progress reporting.
The callback receives (bytes_downloaded, total_bytes); total is 0 when
the server sends no Content-Length, and the count restarts from zero if
an attempt is retried. dest only appears once the file is complete.
Sourcepub fn stream_to_file(
&self,
track_id: &str,
dest: &Path,
on_progress: impl Fn(u64, u64),
) -> Result<(), SubsonicError>
pub fn stream_to_file( &self, track_id: &str, dest: &Path, on_progress: impl Fn(u64, u64), ) -> Result<(), SubsonicError>
Fetch a track through /rest/stream instead of /rest/download.
download returns the untranscoded original and is what library sync
wants from Navidrome. koan’s own server implements only stream, so
that is how the remote bridge pulls audio from a koan serve instance.
Sourcepub fn search(&self, query: &str) -> Result<SubsonicSearchResult, SubsonicError>
pub fn search(&self, query: &str) -> Result<SubsonicSearchResult, SubsonicError>
Search for tracks/albums/artists.
Sourcepub fn star(&self, track_id: &str) -> Result<(), SubsonicError>
pub fn star(&self, track_id: &str) -> Result<(), SubsonicError>
Star (favourite) a track on the server.
Sourcepub fn unstar(&self, track_id: &str) -> Result<(), SubsonicError>
pub fn unstar(&self, track_id: &str) -> Result<(), SubsonicError>
Unstar (unfavourite) a track on the server.
Sourcepub fn get_starred(&self) -> Result<Vec<SubsonicSong>, SubsonicError>
pub fn get_starred(&self) -> Result<Vec<SubsonicSong>, SubsonicError>
Get all starred (favourite) songs from the server.
Sourcepub fn get_starred_all(&self) -> Result<SubsonicStarred, SubsonicError>
pub fn get_starred_all(&self) -> Result<SubsonicStarred, SubsonicError>
Everything the server has starred: songs, albums and artists.
Subsonic returns all three from one call, so asking for songs alone leaves a starred album invisible to us for no saving.
Sourcepub fn star_album(&self, album_id: &str) -> Result<(), SubsonicError>
pub fn star_album(&self, album_id: &str) -> Result<(), SubsonicError>
Star an album. Subsonic keys this off a different parameter to a song —
id would be read as a track and silently star nothing.
pub fn unstar_album(&self, album_id: &str) -> Result<(), SubsonicError>
pub fn star_artist(&self, artist_id: &str) -> Result<(), SubsonicError>
pub fn unstar_artist(&self, artist_id: &str) -> Result<(), SubsonicError>
Create a sharing link for one or more resources (songs, albums, etc). Returns the created share including its ID which forms the public URL.
Sourcepub fn get_similar_songs(
&self,
song_id: &str,
count: usize,
) -> Result<Vec<SubsonicSong>, SubsonicError>
pub fn get_similar_songs( &self, song_id: &str, count: usize, ) -> Result<Vec<SubsonicSong>, SubsonicError>
Get similar songs for a track (Subsonic getSimilarSongs2 endpoint).
Returns up to count similar songs based on the server’s algorithm.
Sourcepub fn get_top_songs(
&self,
artist_name: &str,
count: usize,
) -> Result<Vec<SubsonicSong>, SubsonicError>
pub fn get_top_songs( &self, artist_name: &str, count: usize, ) -> Result<Vec<SubsonicSong>, SubsonicError>
Get top songs for an artist by name.
Auto Trait Implementations§
impl !RefUnwindSafe for SubsonicClient
impl !UnwindSafe for SubsonicClient
impl Freeze for SubsonicClient
impl Send for SubsonicClient
impl Sync for SubsonicClient
impl Unpin for SubsonicClient
impl UnsafeUnpin for SubsonicClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);