pub struct RedseatClient { /* private fields */ }Expand description
Client of one Redseat server. Cheap to clone; clones share the token.
Implementations§
Source§impl RedseatClient
impl RedseatClient
pub fn new(options: ClientOptions) -> Self
Sourcepub async fn connect_http(
server: &CloudServer,
cloud: CloudClient,
session_token: impl Into<String>,
connect: ConnectOptions,
) -> Result<Self>
pub async fn connect_http( server: &CloudServer, cloud: CloudClient, session_token: impl Into<String>, connect: ConnectOptions, ) -> Result<Self>
Connects to server over HTTP: picks its best address (see
crate::http::HttpTransport::connect) and gets server tokens from the cloud
with the user’s session.
Sourcepub fn set_token(&self, token: ServerToken)
pub fn set_token(&self, token: ServerToken)
Sets the server token, for example one the app kept from a previous run.
Sourcepub async fn valid_token(&self) -> Result<ServerToken>
pub async fn valid_token(&self) -> Result<ServerToken>
The current server token, refreshed first when it expires soon.
The absolute URL of path with query, and a valid token to open it. Fails
when the transport is not HTTP (see Transport::http_base_url).
Sourcepub async fn request(&self, request: Request) -> Result<Response>
pub async fn request(&self, request: Request) -> Result<Response>
An authenticated request. A refused token (401) is refreshed and the request sent once more.
Sourcepub async fn get_json<T: DeserializeOwned>(&self, path: &str) -> Result<T>
pub async fn get_json<T: DeserializeOwned>(&self, path: &str) -> Result<T>
GET path read as JSON.
Sourcepub async fn get_json_with<T: DeserializeOwned>(
&self,
request: Request,
) -> Result<T>
pub async fn get_json_with<T: DeserializeOwned>( &self, request: Request, ) -> Result<T>
A request whose answer is read as JSON.
Sourcepub async fn subscribe_raw(
&self,
request: EventRequest,
) -> Result<RawEventStream>
pub async fn subscribe_raw( &self, request: EventRequest, ) -> Result<RawEventStream>
Opens an authenticated event stream, as the transport received it.
Sourcepub async fn subscribe_events(
&self,
options: EventOptions,
) -> Result<ServerEventStream>
pub async fn subscribe_events( &self, options: EventOptions, ) -> Result<ServerEventStream>
Server events (GET /sse), typed. Heartbeats are left out. The stream ends when
the connection does: reconnecting is up to the caller.