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 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. Returns it
unchanged when the library is not encrypted.
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.