@@ -39,24 +39,33 @@ pub enum Finalized {
39
39
Exhausted ,
40
40
Withdraw ,
41
41
}
42
-
43
42
pub mod units_for_slot {
44
43
pub mod response {
45
44
use crate :: { targeting:: Rule , BigNum , ChannelId , ChannelSpec , SpecValidators , ValidatorId } ;
46
45
use chrono:: {
47
46
serde:: { ts_milliseconds, ts_milliseconds_option} ,
48
47
DateTime , Utc ,
49
48
} ;
50
- use serde:: Serialize ;
49
+ use serde:: { Deserialize , Serialize } ;
50
+ use url:: Url ;
51
+
52
+ #[ derive( Debug , Serialize , Deserialize ) ]
53
+ #[ serde( rename_all = "camelCase" ) ]
54
+ pub struct Response {
55
+ pub targeting_input_base : Vec < Rule > ,
56
+ pub accepted_referrers : Vec < Url > ,
57
+ pub fallback_unit : AdUnit ,
58
+ pub campaigns : Vec < Campaign > ,
59
+ }
51
60
52
- #[ derive( Debug , Serialize ) ]
61
+ #[ derive( Debug , Serialize , Deserialize ) ]
53
62
#[ serde( rename_all = "camelCase" ) ]
54
63
pub struct UnitsWithPrice {
55
64
pub unit : AdUnit ,
56
65
pub price : BigNum ,
57
66
}
58
67
59
- #[ derive( Debug , Serialize ) ]
68
+ #[ derive( Debug , Serialize , Deserialize ) ]
60
69
#[ serde( rename_all = "camelCase" ) ]
61
70
pub struct Campaign {
62
71
#[ serde( flatten) ]
@@ -65,7 +74,7 @@ pub mod units_for_slot {
65
74
pub units_with_price : Vec < UnitsWithPrice > ,
66
75
}
67
76
68
- #[ derive( Debug , Serialize ) ]
77
+ #[ derive( Debug , Serialize , Deserialize ) ]
69
78
#[ serde( rename_all = "camelCase" ) ]
70
79
pub struct Channel {
71
80
pub id : ChannelId ,
@@ -87,7 +96,7 @@ pub mod units_for_slot {
87
96
}
88
97
}
89
98
90
- #[ derive( Debug , Serialize ) ]
99
+ #[ derive( Debug , Serialize , Deserialize ) ]
91
100
#[ serde( rename_all = "camelCase" ) ]
92
101
pub struct Spec {
93
102
#[ serde( with = "ts_milliseconds" ) ]
@@ -114,7 +123,7 @@ pub mod units_for_slot {
114
123
}
115
124
}
116
125
117
- #[ derive( Debug , Serialize ) ]
126
+ #[ derive( Debug , Serialize , Deserialize , Clone ) ]
118
127
#[ serde( rename_all = "camelCase" ) ]
119
128
pub struct AdUnit {
120
129
/// Same as `ipfs`
@@ -124,13 +133,13 @@ pub mod units_for_slot {
124
133
pub target_url : String ,
125
134
}
126
135
127
- impl From < crate :: AdUnit > for AdUnit {
128
- fn from ( ad_unit : crate :: AdUnit ) -> Self {
136
+ impl From < & crate :: AdUnit > for AdUnit {
137
+ fn from ( ad_unit : & crate :: AdUnit ) -> Self {
129
138
Self {
130
- id : ad_unit. ipfs ,
131
- media_url : ad_unit. media_url ,
132
- media_mime : ad_unit. media_mime ,
133
- target_url : ad_unit. target_url ,
139
+ id : ad_unit. ipfs . clone ( ) ,
140
+ media_url : ad_unit. media_url . clone ( ) ,
141
+ media_mime : ad_unit. media_mime . clone ( ) ,
142
+ target_url : ad_unit. target_url . clone ( ) ,
134
143
}
135
144
}
136
145
}
0 commit comments