1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
pub mod reply; pub mod request; pub use reply::{Reply, ReplyError}; pub use request::{ LazilyTransformedRequest, Request, TransformRequestError, TransformRule, }; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; #[derive(JsonSchema, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] #[serde(untagged)] pub enum Content { Request(Request), Reply(Reply), } impl Content { pub fn into_request(self) -> Option<Request> { match self { Self::Request(x) => Some(x), Self::Reply(_) => None, } } pub fn into_reply(self) -> Option<Reply> { match self { Self::Request(_) => None, Self::Reply(x) => Some(x), } } pub fn into_reply_error(self) -> Option<ReplyError> { match self.into_reply() { Some(Reply::Error(x)) => Some(x), _ => None, } } } impl crate::core::SchemaInfo for Content {} impl From<Request> for Content { fn from(request: Request) -> Self { Self::Request(request) } } impl From<Reply> for Content { fn from(reply: Reply) -> Self { Self::Reply(reply) } } impl From<ReplyError> for Content { fn from(reply_error: ReplyError) -> Self { Self::from(Reply::Error(reply_error)) } }