1use anyhow::Error;
6use fidl_fuchsia_paver as paver;
7use serde::{Deserialize, Serialize};
8
9#[derive(Debug)]
11pub(super) enum Method {
12 QueryActiveConfiguration,
13 QueryCurrentConfiguration,
14 QueryConfigurationStatus,
15 ReadAsset,
16}
17
18impl std::str::FromStr for Method {
19 type Err = Error;
20
21 fn from_str(method: &str) -> Result<Self, Self::Err> {
22 match method {
23 "QueryActiveConfiguration" => Ok(Method::QueryActiveConfiguration),
24 "QueryCurrentConfiguration" => Ok(Method::QueryCurrentConfiguration),
25 "QueryConfigurationStatus" => Ok(Method::QueryConfigurationStatus),
26 "ReadAsset" => Ok(Method::ReadAsset),
27 _ => return Err(format_err!("Invalid paver facade method: {}", method)),
28 }
29 }
30}
31
32#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
34#[serde(rename_all = "snake_case")]
35pub(super) enum Configuration {
36 A,
37 B,
38 Recovery,
39}
40
41impl From<paver::Configuration> for Configuration {
42 fn from(x: paver::Configuration) -> Self {
43 match x {
44 paver::Configuration::A => Configuration::A,
45 paver::Configuration::B => Configuration::B,
46 paver::Configuration::Recovery => Configuration::Recovery,
47 }
48 }
49}
50
51impl From<Configuration> for paver::Configuration {
52 fn from(x: Configuration) -> Self {
53 match x {
54 Configuration::A => paver::Configuration::A,
55 Configuration::B => paver::Configuration::B,
56 Configuration::Recovery => paver::Configuration::Recovery,
57 }
58 }
59}
60
61#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
63#[serde(rename_all = "snake_case")]
64pub(super) enum Asset {
65 Kernel,
66 VerifiedBootMetadata,
67}
68
69impl From<paver::Asset> for Asset {
70 fn from(x: paver::Asset) -> Self {
71 match x {
72 paver::Asset::Kernel => Asset::Kernel,
73 paver::Asset::VerifiedBootMetadata => Asset::VerifiedBootMetadata,
74 }
75 }
76}
77
78impl From<Asset> for paver::Asset {
79 fn from(x: Asset) -> Self {
80 match x {
81 Asset::Kernel => paver::Asset::Kernel,
82 Asset::VerifiedBootMetadata => paver::Asset::VerifiedBootMetadata,
83 }
84 }
85}
86
87#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
89#[serde(rename_all = "snake_case")]
90pub(super) enum ConfigurationStatus {
91 Healthy,
92 Pending,
93 Unbootable,
94}
95
96impl From<paver::ConfigurationStatus> for ConfigurationStatus {
97 fn from(x: paver::ConfigurationStatus) -> Self {
98 match x {
99 paver::ConfigurationStatus::Healthy => ConfigurationStatus::Healthy,
100 paver::ConfigurationStatus::Pending => ConfigurationStatus::Pending,
101 paver::ConfigurationStatus::Unbootable => ConfigurationStatus::Unbootable,
102 }
103 }
104}
105
106impl From<ConfigurationStatus> for paver::ConfigurationStatus {
107 fn from(x: ConfigurationStatus) -> Self {
108 match x {
109 ConfigurationStatus::Healthy => paver::ConfigurationStatus::Healthy,
110 ConfigurationStatus::Pending => paver::ConfigurationStatus::Pending,
111 ConfigurationStatus::Unbootable => paver::ConfigurationStatus::Unbootable,
112 }
113 }
114}