#[cfg(feature = "alloc")]
use alloc::boxed::Box;
use crate::{MessageKind, ObjectPath, Serial};
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub(crate) enum OwnedMessageKind {
MethodCall {
path: Box<ObjectPath>,
member: Box<str>,
},
MethodReturn {
reply_serial: Serial,
},
Error {
error_name: Box<str>,
reply_serial: Serial,
},
Signal {
path: Box<ObjectPath>,
member: Box<str>,
},
}
impl OwnedMessageKind {
#[inline]
pub(crate) fn borrow(&self) -> MessageKind<'_> {
match *self {
OwnedMessageKind::MethodCall {
ref path,
ref member,
} => MessageKind::MethodCall { path, member },
OwnedMessageKind::MethodReturn { reply_serial } => {
MessageKind::MethodReturn { reply_serial }
}
OwnedMessageKind::Error {
ref error_name,
reply_serial,
} => MessageKind::Error {
error_name,
reply_serial,
},
OwnedMessageKind::Signal {
ref path,
ref member,
} => MessageKind::Signal { path, member },
}
}
}
impl PartialEq<MessageKind<'_>> for OwnedMessageKind {
#[inline]
fn eq(&self, other: &MessageKind<'_>) -> bool {
*other == *self
}
}