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

36 lines
819 B
Rust
Raw Normal View History

use std::ops::Deref;
use ruma::{api::client::uiaa::UiaaResponse, CanonicalJsonValue, OwnedDeviceId, OwnedServerName, OwnedUserId};
use crate::Error;
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,
pub sender_user: Option<OwnedUserId>,
pub sender_device: Option<OwnedDeviceId>,
pub sender_servername: Option<OwnedServerName>,
// 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 { &self.body }
2020-03-28 18:50:02 +01:00
}
2021-06-30 09:52:01 +02:00
#[derive(Clone)]
pub struct RumaResponse<T>(pub T);
impl<T> From<T> for RumaResponse<T> {
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() }
2021-06-30 09:52:01 +02:00
}