bucky_objects/objects/
action.rs1use crate::*;
2
3use std::convert::TryFrom;
4
5#[derive(Clone, Debug, RawEncode, RawDecode)]
6pub struct ActionDescContent {}
7
8impl DescContent for ActionDescContent {
9 fn obj_type() -> u16 {
10 ObjectTypeCode::Action.into()
11 }
12
13 type OwnerType = Option<ObjectId>;
14 type AreaType = SubDescNone;
15 type AuthorType = SubDescNone;
16 type PublicKeyType = SubDescNone;
17}
18
19#[derive(Clone, Debug, RawEncode, RawDecode)]
20pub struct ActionBodyContent {}
21
22impl BodyContent for ActionBodyContent {}
23
24pub type ActionType = NamedObjType<ActionDescContent, ActionBodyContent>;
25pub type ActionBuilder = NamedObjectBuilder<ActionDescContent, ActionBodyContent>;
26
27pub type ActionDesc = NamedObjectDesc<ActionDescContent>;
28pub type ActionId = NamedObjectId<ActionType>;
29pub type Action = NamedObjectBase<ActionType>;
30
31impl ActionDesc {
32 pub fn action_id(&self) -> ActionId {
33 ActionId::try_from(self.calculate_id()).unwrap()
34 }
35}
36
37impl Action {
38 pub fn new() -> ActionBuilder {
39 let desc_content = ActionDescContent {};
40 let body_content = ActionBodyContent {};
41 ActionBuilder::new(desc_content, body_content)
42 }
43}
44
45#[cfg(test)]
46mod test {
47 use crate::{Action, RawConvertTo, RawFrom};
48
49 #[test]
50 fn action() {
51 let action = Action::new().build();
52
53 let buf = action.to_vec().unwrap();
59 let _obj = Action::clone_from_slice(&buf).unwrap();
60 }
61}