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