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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//! Tools and types used to communicate with Sōzu.
extern crate serde;
/// custom made logging macros
/// Custom buffer used for parsing within the Sōzu codebase.
/// TLS certificates
/// channels used for communication between main process and workers
/// parse TOML config and generate requests from it
/// parse Requests
/// Contains Rust types generated by [`prost`](https://docs.rs/prost/latest/prost/)
/// using the protobuf definition in `command.proto`.
///
/// The two main types are `Request` and `Response`.
///
/// Because these types were originally defined in Rust, and later adapted for protobuf,
/// the Rust translation of the protobuf definition looks a bit weird. Instead of having
/// `Request` being a simple enum with Payload like this:
///
/// ```ignore
/// pub enum Request {
/// SaveState(String),
/// LoadState(String),
/// // ...
/// }
/// ```
///
/// It is defined with `oneof` in protobuf. and looks like this in Rust:
///
/// ```ignore
/// pub struct Request {
/// pub request_type: ::core::option::Option<request::RequestType>,
/// }
///
/// pub mod request {
/// pub enum RequestType {
/// #[prost(string, tag = "1")]
/// SaveState(::prost::alloc::string::String),
/// /// load a state file, given its path
/// #[prost(string, tag = "2")]
/// LoadState(::prost::alloc::string::String),
/// }
/// }
/// ```
///
/// but can be instantiated this way:
///
/// ```ignore
/// let load_state_request: Request = RequestType::LoadState(path).into();
/// ```
///
/// A bit cumbersome, but it is the only way to benefit from protobuf in Rust.
/// File descriptor readiness
/// Helper functions around types received by Sōzu
/// Helper functions around types sent by Sōzu
/// sockets used to pass file descriptors
/// A representation of Sōzu's state
/// A writer used for logging
/// Used only when returning errors