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
use crate::schema::Context;
use clyde_3g_eps_api::ResetTelemetry::Data as ResetTelemetryData;
use clyde_3g_eps_api::ResetTelemetry::Type as ResetTelemetryType;
use juniper::FieldResult;
#[derive(Clone, Debug, GraphQLObject)]
pub struct Data {
pub motherboard: i32,
pub daughterboard: Option<i32>,
}
impl Into<Data> for ResetTelemetryData {
fn into(self) -> Data {
Data {
motherboard: i32::from(self.motherboard),
daughterboard: self.daughterboard.map(i32::from),
}
}
}
#[derive(Clone, Debug, Eq, Hash, GraphQLEnum, PartialEq)]
pub enum Type {
BrownOut,
AutomaticSoftware,
Manual,
Watchdog,
}
impl Into<ResetTelemetryType> for Type {
fn into(self) -> ResetTelemetryType {
match self {
Type::BrownOut => ResetTelemetryType::BrownOut,
Type::AutomaticSoftware => ResetTelemetryType::AutomaticSoftware,
Type::Manual => ResetTelemetryType::Manual,
Type::Watchdog => ResetTelemetryType::Watchdog,
}
}
}
pub struct Telemetry;
graphql_object!(Telemetry: Context as "ResetTelemetry" |&self| {
field brown_out(&executor) -> FieldResult<Data>
{
Ok(executor.context().subsystem().get_reset_telemetry(Type::BrownOut)?)
}
field automatic_software(&executor) -> FieldResult<Data>
{
Ok(executor.context().subsystem().get_reset_telemetry(Type::AutomaticSoftware)?)
}
field manual(&executor) -> FieldResult<Data>
{
Ok(executor.context().subsystem().get_reset_telemetry(Type::Manual)?)
}
field watchdog(&executor) -> FieldResult<Data>
{
Ok(executor.context().subsystem().get_reset_telemetry(Type::Watchdog)?)
}
});