cyfs_base/objects/
app_group.rs

1use crate::*;
2use crate::objects::*;
3use crate::{RawDecode, RawEncode, RawEncodePurpose};
4
5use std::convert::TryFrom;
6
7#[derive(Clone, Debug, RawEncode, RawDecode)]
8pub struct AppGroupDescContent {}
9
10impl DescContent for AppGroupDescContent {
11    fn obj_type() -> u16 {
12        ObjectTypeCode::AppGroup.into()
13    }
14
15    type OwnerType = Option<ObjectId>;
16    type AreaType = SubDescNone;
17    type AuthorType = SubDescNone;
18    type PublicKeyType = SubDescNone;
19}
20
21#[derive(Clone, Debug, RawEncode, RawDecode)]
22pub struct AppGroupBodyContent {}
23
24impl BodyContent for AppGroupBodyContent {}
25
26pub type AppGroupType = NamedObjType<AppGroupDescContent, AppGroupBodyContent>;
27pub type AppGroupBuilder = NamedObjectBuilder<AppGroupDescContent, AppGroupBodyContent>;
28
29pub type AppGroupDesc = NamedObjectDesc<AppGroupDescContent>;
30pub type AppGroupId = NamedObjectId<AppGroupType>;
31pub type AppGroup = NamedObjectBase<AppGroupType>;
32
33impl AppGroupDesc {
34    pub fn action_id(&self) -> AppGroupId {
35        AppGroupId::try_from(self.calculate_id()).unwrap()
36    }
37}
38
39impl AppGroup {
40    pub fn new() -> AppGroupBuilder {
41        let desc_content = AppGroupDescContent {};
42        let body_content = AppGroupBodyContent {};
43        AppGroupBuilder::new(desc_content, body_content)
44    }
45}
46
47#[cfg(test)]
48mod test {
49    use crate::*;
50    //use std::path::Path;
51
52    #[test]
53    fn app_group() {
54        let action = AppGroup::new().build();
55
56        // let p = Path::new("f:\\temp\\app_group.obj");
57        // if p.parent().unwrap().exists() {
58        //     action.clone().encode_to_file(p, false);
59        // }
60
61        let buf = action.to_vec().unwrap();
62        let _obj = AppGroup::clone_from_slice(&buf).unwrap();
63    }
64}