rusmpp_core/values/message_payload/
borrowed.rs1use rusmpp_macros::Rusmpp;
2
3use crate::types::borrowed::AnyOctetString;
4
5#[derive(Default, Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Rusmpp)]
6#[rusmpp(decode = borrowed)]
7#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
8#[cfg_attr(feature = "serde", derive(::serde::Serialize))]
9pub struct MessagePayload<'a> {
10 #[rusmpp(length = "unchecked")]
11 pub value: AnyOctetString<'a>,
12}
13
14impl<'a> MessagePayload<'a> {
15 pub const fn new(value: AnyOctetString<'a>) -> Self {
16 Self { value }
17 }
18}
19
20impl<'a> From<AnyOctetString<'a>> for MessagePayload<'a> {
21 fn from(value: AnyOctetString<'a>) -> Self {
22 Self::new(value)
23 }
24}
25
26impl<'a> From<MessagePayload<'a>> for AnyOctetString<'a> {
27 fn from(value: MessagePayload<'a>) -> Self {
28 value.value
29 }
30}
31
32#[cfg(test)]
33mod tests {
34 use super::*;
35
36 #[test]
37 fn encode_decode() {
38 crate::tests::borrowed::encode_decode_with_length_test_instances::<MessagePayload>();
39 }
40}