Struct ruma::client::Client [−][src]
pub struct Client<C>(_);
client
only.Expand description
A client for the Matrix client-server API.
Implementations
Client-API specific functionality of Client
.
Log in with a username and password.
In contrast to send_request
, this method stores the access token
returned by the endpoint in this client, in addition to returning it.
pub async fn register_guest(
&'_ self
) -> Result<Response, Error<<C as HttpClient>::Error, UiaaResponse>>
pub async fn register_guest(
&'_ self
) -> Result<Response, Error<<C as HttpClient>::Error, UiaaResponse>>
Register as a guest.
In contrast to send_request
, this method stores the access token
returned by the endpoint in this client, in addition to returning it.
pub async fn register_user(
&'_ self,
username: Option<&'_ str>,
password: &'_ str
) -> Result<Response, Error<<C as HttpClient>::Error, UiaaResponse>>
pub async fn register_user(
&'_ self,
username: Option<&'_ str>,
password: &'_ str
) -> Result<Response, Error<<C as HttpClient>::Error, UiaaResponse>>
Register as a new user on this server.
In contrast to send_request
, this method stores the access token
returned by the endpoint in this client, in addition to returning it.
The username is the local part of the returned user_id. If it is omitted from this request, the server will generate one.
Convenience method that represents repeated calls to the sync_events endpoint as a stream.
Example:
use std::time::Duration;
let mut sync_stream = Box::pin(client.sync(
None,
next_batch_token,
&PresenceState::Online,
Some(Duration::from_secs(30)),
));
while let Some(response) = sync_stream.try_next().await? {
// Do something with the data in the response...
}
Creates a new client using the given underlying HTTP client.
This allows the user to configure the details of HTTP as desired.
Get a copy of the current access_token
, if any.
Useful for serializing and persisting the session to be restored later.
pub async fn send_request<R>(
&'_ self,
request: R
) -> Result<<R as OutgoingRequest>::IncomingResponse, Error<<C as HttpClient>::Error, <R as OutgoingRequest>::EndpointError>> where
R: OutgoingRequest,
pub async fn send_request<R>(
&'_ self,
request: R
) -> Result<<R as OutgoingRequest>::IncomingResponse, Error<<C as HttpClient>::Error, <R as OutgoingRequest>::EndpointError>> where
R: OutgoingRequest,
Makes a request to a Matrix API endpoint.
pub async fn send_customized_request<R, F>(
&'_ self,
request: R,
customize: F
) -> Result<<R as OutgoingRequest>::IncomingResponse, Error<<C as HttpClient>::Error, <R as OutgoingRequest>::EndpointError>> where
R: OutgoingRequest,
F: FnOnce(&mut Request<<C as HttpClient>::RequestBody>) -> Result<(), Error<<C as HttpClient>::Error, <R as OutgoingRequest>::EndpointError>>,
pub async fn send_customized_request<R, F>(
&'_ self,
request: R,
customize: F
) -> Result<<R as OutgoingRequest>::IncomingResponse, Error<<C as HttpClient>::Error, <R as OutgoingRequest>::EndpointError>> where
R: OutgoingRequest,
F: FnOnce(&mut Request<<C as HttpClient>::RequestBody>) -> Result<(), Error<<C as HttpClient>::Error, <R as OutgoingRequest>::EndpointError>>,
Makes a request to a Matrix API endpoint including additional URL parameters.
pub async fn send_request_as<R>(
&'_ self,
user_id: &'_ UserId,
request: R
) -> Result<<R as OutgoingRequest>::IncomingResponse, Error<<C as HttpClient>::Error, <R as OutgoingRequest>::EndpointError>> where
R: OutgoingRequest,
pub async fn send_request_as<R>(
&'_ self,
user_id: &'_ UserId,
request: R
) -> Result<<R as OutgoingRequest>::IncomingResponse, Error<<C as HttpClient>::Error, <R as OutgoingRequest>::EndpointError>> where
R: OutgoingRequest,
Makes a request to a Matrix API endpoint as a virtual user.
This method is meant to be used by application services when interacting with the client-server API.
Trait Implementations
Auto Trait Implementations
impl<C> RefUnwindSafe for Client<C> where
C: RefUnwindSafe,
impl<C> UnwindSafe for Client<C> where
C: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more