@@ -51,6 +51,7 @@ pub struct TaskBuilder<'a> {
51
51
binary : GWasmBinary < ' a > ,
52
52
name : Option < String > ,
53
53
bid : Option < f64 > ,
54
+ budget : Option < f64 > ,
54
55
timeout : Option < Timeout > ,
55
56
subtask_timeout : Option < Timeout > ,
56
57
input_dir_path : PathBuf ,
@@ -66,6 +67,7 @@ impl<'a> TaskBuilder<'a> {
66
67
binary,
67
68
name : None ,
68
69
bid : None ,
70
+ budget : None ,
69
71
timeout : None ,
70
72
subtask_timeout : None ,
71
73
input_dir_path : workspace. as_ref ( ) . join ( "in" ) ,
@@ -87,6 +89,12 @@ impl<'a> TaskBuilder<'a> {
87
89
self
88
90
}
89
91
92
+ /// Sets task's budget value
93
+ pub fn budget ( mut self , budget : f64 ) -> Self {
94
+ self . budget = Some ( budget) ;
95
+ self
96
+ }
97
+
90
98
/// Sets task's [`Timeout`](../timeout/struct.Timeout.html) value
91
99
pub fn timeout ( mut self , timeout : Timeout ) -> Self {
92
100
self . timeout = Some ( timeout) ;
@@ -185,7 +193,14 @@ impl<'a> TaskBuilder<'a> {
185
193
options. subtasks . insert ( name, subtask) ;
186
194
}
187
195
188
- Ok ( Task :: new ( name, bid, timeout, subtask_timeout, options) )
196
+ Ok ( Task :: new (
197
+ name,
198
+ bid,
199
+ self . budget ,
200
+ timeout,
201
+ subtask_timeout,
202
+ options,
203
+ ) )
189
204
}
190
205
}
191
206
@@ -219,6 +234,8 @@ pub struct Task {
219
234
task_type : String ,
220
235
name : String ,
221
236
bid : f64 ,
237
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
238
+ budget : Option < f64 > ,
222
239
timeout : Timeout ,
223
240
subtask_timeout : Timeout ,
224
241
options : Options ,
@@ -229,6 +246,7 @@ impl Task {
229
246
pub fn new < S : Into < String > > (
230
247
name : S ,
231
248
bid : f64 ,
249
+ budget : Option < f64 > ,
232
250
timeout : Timeout ,
233
251
subtask_timeout : Timeout ,
234
252
options : Options ,
@@ -237,6 +255,7 @@ impl Task {
237
255
task_type : "wasm" . into ( ) ,
238
256
name : name. into ( ) ,
239
257
bid,
258
+ budget,
240
259
timeout,
241
260
subtask_timeout,
242
261
options,
@@ -253,6 +272,11 @@ impl Task {
253
272
self . bid
254
273
}
255
274
275
+ /// Task's budget value
276
+ pub fn budget ( & self ) -> Option < f64 > {
277
+ self . budget
278
+ }
279
+
256
280
/// Task's [`Timeout`](../timeout/struct.Timeout.html) value
257
281
pub fn timeout ( & self ) -> & Timeout {
258
282
& self . timeout
0 commit comments