1
0
Fork 0
ruma/crates/ruma-common/tests/it/api/ui/request-only.rs
Kévin Commaille 6faf8040de api: Rename MatrixError to Error
The `Matrix` prefix is redundant in a crate about the Matrix protocol,
besides this type is not even specific to Matrix.
2026-04-05 11:11:56 +02:00

56 lines
1.2 KiB
Rust

#![allow(unexpected_cfgs)]
use bytes::BufMut;
use ruma_common::{
api::{
IncomingResponse, OutgoingResponse,
auth_scheme::NoAuthentication,
error::{Error, FromHttpResponseError, IntoHttpError},
request,
},
metadata,
};
metadata! {
method: POST, // An `http::Method` constant. No imports required.
rate_limited: false,
authentication: NoAuthentication,
history: {
unstable => "/_matrix/some/endpoint/{foo}",
}
}
#[request]
#[derive(PartialEq)] // Make sure attributes work
pub struct Request {
// With no attribute on the field, it will be put into the body of the request.
#[ruma_api(path)]
pub foo: String,
}
pub struct Response;
impl IncomingResponse for Response {
type EndpointError = Error;
fn try_from_http_response<T: AsRef<[u8]>>(
_: http::Response<T>,
) -> Result<Self, FromHttpResponseError<Error>> {
todo!()
}
}
impl OutgoingResponse for Response {
fn try_into_http_response<T: Default + BufMut>(
self,
) -> Result<http::Response<T>, IntoHttpError> {
todo!()
}
}
fn main() {
let req1 = Request { foo: "foo".into() };
let req2 = req1.clone();
assert_eq!(req1, req2);
}