-
Notifications
You must be signed in to change notification settings - Fork 5
/
resources.rs
71 lines (55 loc) · 1.97 KB
/
resources.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use sails_rs::prelude::*;
pub type PartId = u32;
pub type ResourceId = u8;
#[derive(Decode, Encode, TypeInfo, Clone, Debug, PartialEq, Eq)]
#[codec(crate = sails_rs::scale_codec)]
#[scale_info(crate = sails_rs::scale_info)]
pub enum Resource {
Basic(BasicResource),
Slot(SlotResource),
Composed(ComposedResource),
}
#[derive(Decode, Encode, TypeInfo, Clone, Debug, PartialEq, Eq)]
#[codec(crate = sails_rs::scale_codec)]
#[scale_info(crate = sails_rs::scale_info)]
pub struct BasicResource {
/// URI like IPFS hash
pub src: String,
/// If the resource has the thumb property, this will be a URI to a thumbnail of the given
/// resource.
pub thumb: Option<String>,
/// Reference to IPFS location of metadata
pub metadata_uri: String,
}
#[derive(Decode, Encode, TypeInfo, Clone, Debug, PartialEq, Eq)]
#[codec(crate = sails_rs::scale_codec)]
#[scale_info(crate = sails_rs::scale_info)]
pub struct ComposedResource {
/// URI like ipfs hash
pub src: String,
/// If the resource has the thumb property, this will be a URI to a thumbnail of the given
/// resource.
pub thumb: String,
/// Reference to IPFS location of metadata
pub metadata_uri: String,
// The address of base contract
pub base: ActorId,
// If a resource is composed, it will have an array of parts that compose it
pub parts: Vec<PartId>,
}
#[derive(Decode, Encode, TypeInfo, Clone, Debug, PartialEq, Eq)]
#[codec(crate = sails_rs::scale_codec)]
#[scale_info(crate = sails_rs::scale_info)]
pub struct SlotResource {
/// URI like ipfs hash
pub src: String,
/// If the resource has the thumb property, this will be a URI to a thumbnail of the given
/// resource.
pub thumb: String,
/// Reference to IPFS location of metadata
pub metadata_uri: String,
// The address of base contract
pub base: ActorId,
/// If the resource has the slot property, it was designed to fit into a specific Base's slot.
pub slot: PartId,
}