use crate::{channel::Channel, command::Command, message::Message};
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct Transaction<T: AsRef<[u8]>, S: AsRef<[u8]>> {
pub channel: Channel,
pub command: Command,
pub request: T,
pub response: S,
}
impl<T: AsRef<[u8]>, S: AsRef<[u8]>> Transaction<T, S> {
pub fn request_message(&self) -> Message<&[u8]> {
Message {
channel: self.channel,
command: self.command,
data: self.request.as_ref(),
}
}
pub fn response_message(&self) -> Message<&[u8]> {
Message {
channel: self.channel,
command: self.command,
data: self.response.as_ref(),
}
}
}