1
0
Fork 0
mirror of https://forgejo.ellis.link/continuwuation/continuwuity.git synced 2025-07-28 02:38:30 +00:00
continuwuity/src/api/ruma_wrapper/mod.rs

43 lines
922 B
Rust
Raw Normal View History

2022-01-20 11:51:31 +01:00
use crate::Error;
use ruma::{
2022-04-06 21:31:29 +02:00
api::client::uiaa::UiaaResponse, signatures::CanonicalJsonValue, DeviceId, ServerName, UserId,
};
use std::ops::Deref;
#[cfg(feature = "conduit_bin")]
2022-01-20 11:51:31 +01:00
mod axum;
2020-02-15 22:42:21 +01:00
2022-01-20 11:51:31 +01:00
/// Extractor for Ruma request structs
2022-04-06 21:31:29 +02:00
pub struct Ruma<T> {
pub body: T,
2021-11-26 20:36:40 +01:00
pub sender_user: Option<Box<UserId>>,
pub sender_device: Option<Box<DeviceId>>,
pub sender_servername: Option<Box<ServerName>>,
2021-04-23 19:04:59 +02:00
// This is None when body is not a valid string
pub json_body: Option<CanonicalJsonValue>,
pub from_appservice: bool,
2020-03-28 18:50:02 +01:00
}
2020-03-28 23:08:59 +01:00
2022-04-06 21:31:29 +02:00
impl<T> Deref for Ruma<T> {
type Target = T;
2020-02-15 22:42:21 +01:00
fn deref(&self) -> &Self::Target {
2020-03-28 18:50:02 +01:00
&self.body
}
}
2021-06-30 09:52:01 +02:00
#[derive(Clone)]
pub struct RumaResponse<T>(pub T);
impl<T> From<T> for RumaResponse<T> {
2020-06-09 15:13:17 +02:00
fn from(t: T) -> Self {
Self(t)
2020-02-18 22:07:57 +01:00
}
}
2021-06-30 09:52:01 +02:00
impl From<Error> for RumaResponse<UiaaResponse> {
fn from(t: Error) -> Self {
t.to_response()
}
}