Skip to main content

LibraryApi

Struct LibraryApi 

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

Calls on one library. Cheap to clone; clones share the passphrase.

Implementations§

Source§

impl LibraryApi

Source

pub fn new(client: RedseatClient, library: ServerLibraryForRead) -> Self

Source

pub fn id(&self) -> &str

Source

pub fn library(&self) -> &ServerLibraryForRead

Source

pub fn client(&self) -> &RedseatClient

The client of the library’s server.

Source

pub fn is_encrypted(&self) -> bool

Whether files are encrypted on the client side (crypt).

Source

pub fn has_passphrase(&self) -> bool

Whether the passphrase is set.

Source

pub async fn get_medias(&self, query: &MediaQuery) -> Result<Vec<MediaItem>>

Medias matching query. Timestamps are Unix milliseconds.

Source

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.

Source

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.

Source

pub async fn get_thumb(&self, media: &Media) -> Result<Vec<u8>>

The thumbnail of media, decrypted in an encrypted library (set the passphrase first).

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn count_medias(&self, query: &MediaQuery) -> Result<u64>

The number of medias matching query (its limit and page_key are ignored).

Source

pub async fn get_tags(&self, query: &TagQuery) -> Result<Vec<Tag>>

The tags of the library matching query. With after, only those modified strictly after it (Unix milliseconds); page with limit and offset.

Source

pub async fn get_people(&self, query: &PeopleQuery) -> Result<Vec<Person>>

The people of the library matching query, like Self::get_tags.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn clear_passphrase(&self)

Forgets the passphrase.

Trait Implementations§

Source§

impl Clone for LibraryApi

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LibraryApi

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for LibraryApi

§

impl !UnwindSafe for LibraryApi

§

impl Forget for LibraryApi

§

impl Freeze for LibraryApi
where *const ArcInner<Inner> is !null: Freeze, PhantomData<ArcInner<Inner>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<UserMapping>: Freeze, PhantomData<LibraryRole>: Freeze, *const ArcInner<Mutex<Option<[u8; 32]>>> is !null: Freeze, PhantomData<ArcInner<Mutex<Option<[u8; 32]>>>>: Freeze,

§

impl Move for LibraryApi

§

impl Send for LibraryApi
where Arc<Inner>: Send, RawVecInner: Send, Arc<Mutex<Option<[u8; 32]>>>: Send,

§

impl Sync for LibraryApi
where Arc<Inner>: Sync, RawVecInner: Sync, Arc<Mutex<Option<[u8; 32]>>>: Sync,

§

impl Unpin for LibraryApi
where Arc<Inner>: Unpin, *const u8 is !null: Unpin, Arc<Mutex<Option<[u8; 32]>>>: Unpin,

§

impl UnsafeUnpin for LibraryApi

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> MaybeSend for T
where T: Send + Sync + ?Sized,

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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