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.
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.
Trait Implementations§
Source§impl Clone for RedseatClient
impl Clone for RedseatClient
Auto Trait Implementations§
impl !RefUnwindSafe for RedseatClient
impl !UnwindSafe for RedseatClient
impl Forget for RedseatClient
impl Freeze for RedseatClient
impl Move for RedseatClient
impl Send for RedseatClient
impl Sync for RedseatClient
impl Unpin for RedseatClient
impl UnsafeUnpin for RedseatClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more