use super::*;
pub struct Inbound(pub(crate) bus::Inbound);
impl Inbound {
pub fn payload(&self) -> &Payload {
&self.0.payload
}
}
impl core::ops::Deref for Inbound {
type Target = Payload;
fn deref(&self) -> &Self::Target {
&self.0.payload
}
}
impl core::ops::DerefMut for Inbound {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0.payload
}
}
impl From<Inbound> for Payload {
fn from(value: Inbound) -> Self {
value.0.payload
}
}
impl core::fmt::Debug for Inbound {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("Inbound")
.field("payload", self.payload())
.finish()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_inbound() {
let payload = Bytes::from_static(b"hello");
let inbound = Inbound(bus::Inbound {
payload: payload.clone(),
});
assert_eq!(&*inbound, &payload);
assert_eq!(inbound.payload(), &payload);
assert_eq!(Payload::from(inbound), payload);
}
}