rusmpp_core/values/message_payload/
owned.rs

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