Skip to main content

Crate redseat_api

Crate redseat_api 

Source
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 (feature desktop-auth, not on wasm): Google sign-in in the browser for desktop apps.
  • RedseatClient: requests to one server through a Transport, with the server token refreshed before it expires, and its events as a typed stream.
  • ServerApi and LibraryApi: libraries, medias, thumbnails.
  • http (feature http, 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 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/api client.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-http direct.ts and of the candidate order of the web app’s direct-access.ts.
error
The error type of the crate. Its kinds follow the TypeScript RedseatErrorKind (@redseat/api transport.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.ts createEventStream); the payloads are the shared types.
google
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-http http-transport.ts and client.ts, with the address choice of direct.ts.
library
Calls on one library. Port of the media list, thumbnail and key parts of @redseat/api library.ts; the next-page key follows the web app’s MediasList.svelte.
server
Server-wide calls. Port of the start of @redseat/api server.ts.
sse
Server-Sent Events parsing. Port of @redseat/api-http sse-fetch.ts (parseSSEBuffer), plus an incremental decoder for byte chunks.
transport
The Transport trait: how the client reaches a server. Port of @redseat/api transport.ts. The HTTP implementation is crate::http::HttpTransport; WebRTC can come later behind its own feature.
types
Data exchanged with the server: libraries, medias, movies, series, events…