use serde::Deserialize;
use xml_struct::XmlSerialize;
pub trait Operation: XmlSerialize + sealed::EnvelopeBodyContents + std::fmt::Debug {
type Response: OperationResponse;
const NAME: &'static str;
}
impl<T> Operation for &T
where
T: Operation,
{
type Response = T::Response;
const NAME: &'static str = <T as Operation>::NAME;
}
pub trait OperationResponse:
for<'de> Deserialize<'de> + sealed::EnvelopeBodyContents + std::fmt::Debug
{
type Message;
fn response_messages(&self) -> &[crate::ResponseClass<Self::Message>];
fn into_response_messages(self) -> Vec<crate::ResponseClass<Self::Message>>;
}
pub(super) mod sealed {
pub trait EnvelopeBodyContents {
const NAME: &'static str;
}
impl<T> EnvelopeBodyContents for &T
where
T: EnvelopeBodyContents,
{
const NAME: &'static str = T::NAME;
}
}