-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.rs
58 lines (51 loc) · 1.23 KB
/
demo.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
use anchor_lang::prelude::*;
#[derive(AnchorSerialize, AnchorDeserialize, Default, Clone, Debug)]
pub struct Square {
pub size: u16,
pub color: String,
}
impl Square {
pub const fn new(size: u16, color: String) -> Self {
Self {
size: size,
color: color,
}
}
}
// How to implement derive
//https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/book/first-edition/procedural-macros.html
#[derive(AnchorSerialize, AnchorDeserialize, Default, Clone, Debug)]
pub struct Circle {
pub size: u16,
pub color: String,
}
impl Circle {
pub const fn new(size: u16, color: String) -> Self {
Self {
size: size,
color: color,
}
}
}
#[derive(AnchorSerialize, AnchorDeserialize, Default, Clone, Debug)]
pub struct Triangle {
pub size: u16,
pub color: String,
}
impl Triangle {
pub const fn new(size: u16, color: String) -> Self {
Self {
size: size,
color: color,
}
}
}
#[account]
pub struct Demo {
pub authority: Pubkey,
pub sol_cerberus_app: Pubkey,
pub bump: u8,
pub square: Option<Square>,
pub circle: Option<Circle>,
pub triangle: Option<Triangle>,
}