cyfs_base_meta/
sn_service.rs1use cyfs_base::*;
2
3#[derive(Clone, Debug, RawEncode, RawDecode)]
4pub struct SNServiceDescContent {
5 pub service_type: u8,
6 pub price: u64,
7}
8
9impl DescContent for SNServiceDescContent {
10 fn obj_type() -> u16 {
11 0_16
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 SNServiceBodyContent {}
23
24impl BodyContent for SNServiceBodyContent {}
25
26pub type SNServiceType = NamedObjType<SNServiceDescContent, SNServiceBodyContent>;
27pub type SNServiceBuilder = NamedObjectBuilder<SNServiceDescContent, SNServiceBodyContent>;
28pub type SNService = NamedObjectBase<SNServiceType>;
29
30pub trait SNServiceTrait {
31 fn new(owner: ObjectId, service_type: u8, price: u64) -> SNServiceBuilder;
32}
33
34impl SNServiceTrait for NamedObjectBase<SNServiceType> {
35 fn new(owner: ObjectId, service_type: u8, price: u64) -> SNServiceBuilder {
36 let desc = SNServiceDescContent {
37 service_type,
38 price,
39 };
40 let body = SNServiceBodyContent {};
41
42 SNServiceBuilder::new(desc, body).owner(owner)
43 }
44}
45
46#[derive(Clone, Debug, RawEncode, RawDecode)]
47pub enum ServiceAuthType {
48 Any,
49 WhiteList,
50 BlackList,
51}
52
53#[derive(Clone, Debug, RawEncode, RawDecode)]
54pub struct SNContractBodyContent {
55 auth_type: ServiceAuthType,
56 list: Vec<ObjectId>,
57}
58
59#[derive(Clone, Debug, RawEncode, RawDecode)]
60pub struct SNPurchase {
61 pub service_id: ObjectId,
62 pub start_time: u64,
63 pub stop_time: u64,
64 pub auth_type: ServiceAuthType,
65 pub auth_list: Vec<ObjectId>,
66}