1use crate::Encode;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
5pub struct Meta<'a> {
6 pub app_id: &'a str,
7 pub app_name: &'a str,
9 pub author_id: &'a str,
10 pub author_name: &'a str,
11 pub launcher: bool,
13 pub sudo: bool,
15 pub version: u32,
18}
19
20impl<'a> Encode<'a> for Meta<'a> {}
21
22#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
28#[allow(clippy::module_name_repetitions)]
29pub struct ShortMeta<'a> {
30 pub app_id: &'a str,
31 pub author_id: &'a str,
32}
33
34impl<'a> Encode<'a> for ShortMeta<'a> {}
35
36#[cfg(test)]
37mod tests {
38 use super::*;
39
40 #[test]
41 fn test_meta_roundtrip() {
42 let given = Meta {
43 app_id: "some-app-id",
44 app_name: "Some App Name",
45 author_id: "some-author-id",
46 author_name: "Some Author Name",
47 launcher: false,
48 sudo: false,
49 version: 12,
50 };
51 let mut buf = vec![0; given.size()];
52 let raw = given.encode_buf(&mut buf).unwrap();
53 let actual = Meta::decode(raw).unwrap();
54 assert_eq!(given, actual);
55 }
56
57 #[test]
58 fn test_short_meta_roundtrip() {
59 let given = ShortMeta {
60 app_id: "some-app-id",
61 author_id: "some-author-id",
62 };
63 let mut buf = vec![0; given.size()];
64 let raw = given.encode_buf(&mut buf).unwrap();
65 let actual = ShortMeta::decode(raw).unwrap();
66 assert_eq!(given, actual);
67 }
68}