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
use Context as AnyhowCtx;
use DeserializeOwned;
use crateExtractionError;
use crateSystem as SystemState;
use crate;
/// Extracts the global system state managed by the [Worker](`crate::worker::Worker`)
///
/// This extractor is useful for Jobs that need to *peek* into another part of the system state
/// outside the scope given by the assigned path. Note that using this extractor makes the Job not
/// able to run concurrently.
///
/// # Example
///
/// ```rust,no_run
/// use mahler::{
/// extract::System,
/// task::{Handler, update},
/// worker::{Worker, Ready}
/// };
/// use serde::{Serialize, Deserialize};
///
/// #[derive(Serialize,Deserialize)]
/// struct SystemState {/* ... */};
///
/// fn accessing_global_state(System(state): System<SystemState>) {
/// // ...
/// }
///
/// let worker: Worker<SystemState, Ready> = Worker::new()
/// .job("/{foo}/{bar}", update(accessing_global_state))
/// .initial_state(SystemState {/* ... */})
/// .unwrap();
/// ```
///
/// # Errors
///
/// Initializing the extractor will fail if the worker state cannot be deserialized into type
/// `<S>`.
;