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, thumbnails.http(featurehttp, default): the HTTP + SSE transport, and the choice of the server address.
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 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 server::ServerApi;pub use transport::Transport;pub use redseat_crypto as crypto;
Modules§
- 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 the media list, thumbnail and key parts of
@redseat/apilibrary.ts; the next-page key follows the web app’sMediasList.svelte. - server
- Server-wide calls. Port of the start of
@redseat/apiserver.ts. - 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…