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: ServerLibrary) -> Self
pub fn id(&self) -> &str
pub fn library(&self) -> &ServerLibrary
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.
The tags of the library.
Sourcepub async fn get_people(&self) -> Result<Vec<Person>>
pub async fn get_people(&self) -> Result<Vec<Person>>
The people of the library.
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.