Trait ruma_common::api::OutgoingRequest
source · pub trait OutgoingRequest: Sized + Clone {
type EndpointError: EndpointError;
type IncomingResponse: IncomingResponse<EndpointError = Self::EndpointError>;
const METADATA: Metadata;
// Required method
fn try_into_http_request<T: Default + BufMut>(
self,
base_url: &str,
access_token: SendAccessToken<'_>,
considering_versions: &[MatrixVersion],
) -> Result<Request<T>, IntoHttpError>;
}
api
only.Expand description
A request type for a Matrix API endpoint, used for sending requests.
Required Associated Constants§
Required Associated Types§
sourcetype EndpointError: EndpointError
type EndpointError: EndpointError
A type capturing the expected error conditions the server can return.
sourcetype IncomingResponse: IncomingResponse<EndpointError = Self::EndpointError>
type IncomingResponse: IncomingResponse<EndpointError = Self::EndpointError>
Response type returned when the request is successful.
Required Methods§
sourcefn try_into_http_request<T: Default + BufMut>(
self,
base_url: &str,
access_token: SendAccessToken<'_>,
considering_versions: &[MatrixVersion],
) -> Result<Request<T>, IntoHttpError>
fn try_into_http_request<T: Default + BufMut>( self, base_url: &str, access_token: SendAccessToken<'_>, considering_versions: &[MatrixVersion], ) -> Result<Request<T>, IntoHttpError>
Tries to convert this request into an http::Request
.
On endpoints with authentication, when adequate information isn’t provided through access_token, this could result in an error. It may also fail with a serialization error in case of bugs in Ruma though.
It may also fail if, for every version in considering_versions
;
- The endpoint is too old, and has been removed in all versions.
(
EndpointRemoved
) - The endpoint is too new, and no unstable path is known for this endpoint.
(
NoUnstablePath
)
Finally, this will emit a warning through tracing
if it detects if any version in
considering_versions
has deprecated this endpoint.
The endpoints path will be appended to the given base_url
, for example
https://matrix.org
. Since all paths begin with a slash, it is not necessary for the
base_url
to have a trailing slash. If it has one however, it will be ignored.