pub struct LibraryApi { /* private fields */ }Expand description
Calls on one library. Cheap to clone; clones share the passphrase.
Implementations§
Source§impl LibraryApi
impl LibraryApi
pub fn new(client: RedseatClient, library: ServerLibraryForRead) -> Self
pub fn id(&self) -> &str
pub fn library(&self) -> &ServerLibraryForRead
Sourcepub fn client(&self) -> &RedseatClient
pub fn client(&self) -> &RedseatClient
The client of the library’s server.
Sourcepub fn is_encrypted(&self) -> bool
pub fn is_encrypted(&self) -> bool
Whether files are encrypted on the client side (crypt).
Sourcepub fn has_passphrase(&self) -> bool
pub fn has_passphrase(&self) -> bool
Whether the passphrase is set.
Sourcepub async fn get_medias(&self, query: &MediaQuery) -> Result<Vec<MediaItem>>
pub async fn get_medias(&self, query: &MediaQuery) -> Result<Vec<MediaItem>>
Medias matching query. Timestamps are Unix milliseconds.
Sourcepub async fn get_medias_page(&self, query: &MediaQuery) -> Result<MediaPage>
pub async fn get_medias_page(&self, query: &MediaQuery) -> Result<MediaPage>
A page of medias. Set query.limit to the page size, then pass
next_page_key back in query.page_key for the next page.
Sourcepub async fn get_thumb_raw(&self, media_id: &str) -> Result<Vec<u8>>
pub async fn get_thumb_raw(&self, media_id: &str) -> Result<Vec<u8>>
The thumbnail as the server stores it: encrypted in an encrypted library.
Sourcepub async fn get_thumb(&self, media: &Media) -> Result<Vec<u8>>
pub async fn get_thumb(&self, media: &Media) -> Result<Vec<u8>>
The thumbnail of media, decrypted in an encrypted library (set the passphrase
first).
Sourcepub fn decrypt_thumb(&self, media: &Media, data: &[u8]) -> Result<Vec<u8>>
pub fn decrypt_thumb(&self, media: &Media, data: &[u8]) -> Result<Vec<u8>>
Decrypts a thumbnail of media fetched with Self::get_thumb_raw (or its
file, fetched without raw: both are encrypted with the media’s IV). Returns it
unchanged when the library is not encrypted.
Sourcepub async fn get_media(
&self,
media: &Media,
query: &MediaFileQuery,
) -> Result<Vec<u8>>
pub async fn get_media( &self, media: &Media, query: &MediaFileQuery, ) -> Result<Vec<u8>>
The file of a media, whole: decrypted in an encrypted library (set the
passphrase first). With query.unsupported_mime, the server converts photos
of those types (or of any type a browser cannot show, with "all") to WebP;
it cannot in an encrypted library.
Sourcepub async fn media_url(
&self,
media_id: &str,
query: &MediaFileQuery,
) -> Result<AuthorizedUrl>
pub async fn media_url( &self, media_id: &str, query: &MediaFileQuery, ) -> Result<AuthorizedUrl>
The URL of a media file and a token to open it, for a player that streams it
itself with HTTP range requests. The bytes are the stored ones: in an encrypted
library they are encrypted, and the server does not answer range requests, so
use Self::get_media there.
Sourcepub async fn open_encrypted_media(
&self,
media: &Media,
) -> Result<EncryptedMediaReader>
pub async fn open_encrypted_media( &self, media: &Media, ) -> Result<EncryptedMediaReader>
Opens a media of an encrypted library for reading by ranges, decrypted: for a
player that streams and seeks (see EncryptedMediaReader). Set the
passphrase first. Needs a server that answers range requests on encrypted
files; an older one gives an error saying it needs an update.
Sourcepub async fn count_medias(&self, query: &MediaQuery) -> Result<u64>
pub async fn count_medias(&self, query: &MediaQuery) -> Result<u64>
The number of medias matching query (its limit and page_key are ignored).
The tags of the library matching query. With after, only those modified
strictly after it (Unix milliseconds); page with limit and offset.
Sourcepub async fn get_people(&self, query: &PeopleQuery) -> Result<Vec<Person>>
pub async fn get_people(&self, query: &PeopleQuery) -> Result<Vec<Person>>
The people of the library matching query, like Self::get_tags.
Sourcepub async fn get_series(
&self,
query: &SerieQuery,
) -> Result<Vec<ItemWithRelations<Serie>>>
pub async fn get_series( &self, query: &SerieQuery, ) -> Result<Vec<ItemWithRelations<Serie>>>
The series of the library matching query, with their relations, like
Self::get_tags.
Sourcepub async fn get_movies(
&self,
query: &MovieQuery,
) -> Result<Vec<ItemWithRelations<Movie>>>
pub async fn get_movies( &self, query: &MovieQuery, ) -> Result<Vec<ItemWithRelations<Movie>>>
The movies of the library matching query, with their relations, like
Self::get_tags.
Sourcepub async fn get_episodes(&self, query: &EpisodeQuery) -> Result<Vec<Episode>>
pub async fn get_episodes(&self, query: &EpisodeQuery) -> Result<Vec<Episode>>
The episodes of the library matching query (of all series without
serie_ref), like Self::get_tags. An episode’s id is
Episode::id: series, season and number.
Sourcepub async fn get_books(
&self,
query: &BookQuery,
) -> Result<Vec<ItemWithRelations<Book>>>
pub async fn get_books( &self, query: &BookQuery, ) -> Result<Vec<ItemWithRelations<Book>>>
The books of the library matching query, with their relations, like
Self::get_tags.
Sourcepub async fn get_deleted(&self, query: &DeletedQuery) -> Result<Vec<RsDeleted>>
pub async fn get_deleted(&self, query: &DeletedQuery) -> Result<Vec<RsDeleted>>
What was deleted from the library: with after, strictly after it (Unix
milliseconds). Page with limit and offset.
Sourcepub async fn set_passphrase(&self, passphrase: &str) -> Result<()>
pub async fn set_passphrase(&self, passphrase: &str) -> Result<()>
Sets the passphrase of an encrypted library. It is checked on the thumbnail of
one media when there is one: a wrong passphrase gives
Error::InvalidPassphrase, and a failure to fetch that thumbnail its own error.
Sourcepub fn clear_passphrase(&self)
pub fn clear_passphrase(&self)
Forgets the passphrase.