pub struct MatrixRequest<'a, T, U = ClientApi> {
pub meth: Method,
pub endpoint: Cow<'a, str>,
pub params: HashMap<Cow<'a, str>, Cow<'a, str>>,
pub body: T,
pub typ: U,
}Expand description
A arbitrary request to an endpoint in the Matrix API.
To actually determine what URL is used for the request, two things are
consulted: the request type, and the request endpoint. The request type
specifies what Matrix API is being used (for example, the client-server API
revision 0, under /_matrix/client/r0), while the endpoint determines what
method is being called on that API.
This type has Super Cow Powers.
Fields§
§meth: MethodRequest method (exported in the http module)
endpoint: Cow<'a, str>API endpoint (e.g. /sync)
params: HashMap<Cow<'a, str>, Cow<'a, str>>Query-string parameters.
body: TRequest body (some type implementing Serialize).
If this is empty (serialises to {}), it will not be sent. Therefore,
requests with no body should use () here.
typ: URequest type.
Implementations§
Source§impl<'a, T, U> MatrixRequest<'a, T, U>
impl<'a, T, U> MatrixRequest<'a, T, U>
Source§impl<'a> MatrixRequest<'a, ()>
impl<'a> MatrixRequest<'a, ()>
Source§impl<'a, 'b, 'c> MatrixRequest<'a, HashMap<Cow<'b, str>, Cow<'c, str>>>
impl<'a, 'b, 'c> MatrixRequest<'a, HashMap<Cow<'b, str>, Cow<'c, str>>>
Sourcepub fn new_with_body<S, T, U, V>(meth: Method, endpoint: S, body: V) -> Self
pub fn new_with_body<S, T, U, V>(meth: Method, endpoint: S, body: V) -> Self
Makes a MatrixRequest with the following defaults:
methandendpointspecifiedbodyconverted from an iterator over(T, U)where T & U implementInto<Cow<str>>paramsset to an empty hashmaptypset toapis::r0::ClientApi
Source§impl<'a, T> MatrixRequest<'a, T>where
T: Serialize,
impl<'a, T> MatrixRequest<'a, T>where
T: Serialize,
Source§impl<'a, T, U> MatrixRequest<'a, T, U>
impl<'a, T, U> MatrixRequest<'a, T, U>
Sourcepub fn make_request<C>(&self, client: &C) -> MatrixResult<Request<Vec<u8>>>where
C: MatrixRequestable,
pub fn make_request<C>(&self, client: &C) -> MatrixResult<Request<Vec<u8>>>where
C: MatrixRequestable,
Make this MatrixRequest into a HTTP request.
Sourcepub fn send<C, R>(
&self,
mxc: &mut C,
) -> impl Future<Item = R, Error = MatrixError> + 'staticwhere
R: DeserializeOwned + 'static,
C: MatrixRequestable,
pub fn send<C, R>(
&self,
mxc: &mut C,
) -> impl Future<Item = R, Error = MatrixError> + 'staticwhere
R: DeserializeOwned + 'static,
C: MatrixRequestable,
Sends this request to a Matrix homeserver, expecting a deserializable
R return type.
A helpful mix of make_hyper() and MatrixClient::send_request().
Sourcepub fn discarding_send<'x, 'y, C>(
&'x self,
mxc: &'y mut C,
) -> impl Future<Item = (), Error = MatrixError> + 'staticwhere
C: MatrixRequestable,
pub fn discarding_send<'x, 'y, C>(
&'x self,
mxc: &'y mut C,
) -> impl Future<Item = (), Error = MatrixError> + 'staticwhere
C: MatrixRequestable,
Like send(), but uses MatrixClient::send_discarding_request().
Auto Trait Implementations§
impl<'a, T, U> Freeze for MatrixRequest<'a, T, U>
impl<'a, T, U> RefUnwindSafe for MatrixRequest<'a, T, U>where
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<'a, T, U> Send for MatrixRequest<'a, T, U>
impl<'a, T, U> Sync for MatrixRequest<'a, T, U>
impl<'a, T, U> Unpin for MatrixRequest<'a, T, U>
impl<'a, T, U> UnwindSafe for MatrixRequest<'a, T, U>where
T: UnwindSafe,
U: UnwindSafe,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more