Expand description
Rust client for Redseat media servers.
CloudClient: the Redseat cloud: sign-in with a Google ID token, the user’s servers, server tokens.google(featuredesktop-auth, not on wasm): Google sign-in in the browser for desktop apps.RedseatClient: requests to one server through aTransport, with the server token refreshed before it expires, and its events as a typed stream.ServerApiandLibraryApi: libraries, medias and their files, tags, people, series, movies, books, channels, watch history, requests and searches through plugins.http(featurehttp, default): the HTTP + SSE transport, and the choice of the server address.Calland thecallsmodules (server::calls,library::calls,cloud::calls): each call without its I/O, a request and the reader of its answer, for a host that sends requests itself.
The data types are the server’s own, from rs-plugin-common-interfaces
(types), and encrypted libraries use the server’s own implementation, from
redseat-crypto (crypto).
use redseat_api::{CloudClient, RedseatClient, ServerApi};
use redseat_api::types::media::MediaQuery;
let cloud = CloudClient::http()?;
let session = cloud.sign_in_with_google_id_token(google_id_token).await?;
let servers = cloud.list_servers(&session.token).await?;
let client =
RedseatClient::connect_http(&servers[0], cloud, &session.token, Default::default())
.await?;
let server = ServerApi::new(client);
let libraries = server.get_libraries().await?;
let library = server.library(libraries[0].clone());
let query = MediaQuery { limit: Some(10), ..Default::default() };
let page = library.get_medias_page(&query).await?;
let thumb = library.get_thumb(&page.medias[0].item).await?;Re-exports§
pub use call::Call;pub use client::AuthorizedUrl;pub use client::ClientOptions;pub use client::CloudTokenSource;pub use client::EventOptions;pub use client::RedseatClient;pub use client::ServerEventStream;pub use client::ServerTokenSource;pub use cloud::CloudClient;pub use cloud::CloudServer;pub use cloud::CloudSession;pub use cloud::CloudUser;pub use cloud::ServerToken;pub use encrypted::EncryptedMediaReader;pub use error::Error;pub use error::ErrorKind;pub use error::Result;pub use events::ServerEvent;pub use library::LibraryApi;pub use library::MediaItem;pub use library::MediaPage;pub use library::SearchStream;pub use server::ServerApi;pub use transport::Transport;pub use rs_plugin_common_interfaces;pub use redseat_crypto as crypto;
Modules§
- call
- A call to a server or the cloud without its I/O: the
Requestto send and how to read itsResponse. The async clients run calls through acrate::Transport(crate::RedseatClient::run,crate::CloudClient::run); a host that sends requests itself (a WebAssembly module that cannot run async code, a binding to another language) builds the same calls with thecallsmodules (crate::server::calls,crate::library::calls,crate::cloud::calls), sendsCall::requestand reads the answer withCall::parse. - client
RedseatClient: authenticated requests to one server, with the server token refreshed before it expires. Port of@redseat/apiclient.ts.- cloud
- The Redseat cloud (
https://www.redseat.cloud): sign-in and the control plane. - direct
- Which address to reach a server at. Port of
@redseat/api-httpdirect.tsand of the candidate order of the web app’sdirect-access.ts. - encrypted
- Random access to the files of encrypted (
crypt) libraries, for players that stream and seek. - error
- The error type of the crate. Its kinds follow the TypeScript
RedseatErrorKind(@redseat/apitransport.ts), plus a few for sign-in and encryption. - events
- Typed server events. The names are the server’s and the TS client’s
(
sse-types.ts,client.tscreateEventStream); the payloads are the shared types. - Google sign-in in the browser, for desktop apps: OAuth 2.0 for installed apps with a loopback redirect and PKCE (S256). Not available on wasm.
- http
- HTTP + SSE transport, with reqwest and rustls. Port of
@redseat/api-httphttp-transport.tsandclient.ts, with the address choice ofdirect.ts. - library
- Calls on one library. Port of
@redseat/apilibrary.ts, for the calls the Redseat apps use; the next-page key follows the web app’sMediasList.svelte. The server’s routes are the reference for each call, not the TypeScript client. - server
- Server-wide calls. Port of
@redseat/apiserver.ts, for the calls the Redseat apps use. - sse
- Server-Sent Events parsing. Port of
@redseat/api-httpsse-fetch.ts(parseSSEBuffer), plus an incremental decoder for byte chunks. - transport
- The
Transporttrait: how the client reaches a server. Port of@redseat/apitransport.ts. The HTTP implementation iscrate::http::HttpTransport; WebRTC can come later behind its own feature. - types
- Data exchanged with the server: libraries, medias, movies, series, events…