interstice_abi/
authority.rs1use crate::IntersticeAbiError;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, Hash)]
5pub enum Authority {
6 Gpu,
7 Audio,
8 Input,
9 File,
10 Module,
11}
12
13impl Into<String> for Authority {
14 fn into(self) -> String {
15 match self {
16 Authority::Gpu => "Gpu".into(),
17 Authority::Audio => "Audio".into(),
18 Authority::Input => "Input".into(),
19 Authority::File => "File".into(),
20 Authority::Module => "Module".into(),
21 }
22 }
23}
24
25impl TryInto<Authority> for String {
26 type Error = IntersticeAbiError;
27
28 fn try_into(self) -> Result<Authority, Self::Error> {
29 match self.as_str() {
30 "Gpu" => Ok(Authority::Gpu),
31 "Audio" => Ok(Authority::Audio),
32 "Input" => Ok(Authority::Input),
33 "File" => Ok(Authority::File),
34 "Module" => Ok(Authority::Module),
35 _ => Err(IntersticeAbiError::ConversionError(
36 "Couldn't convert String to Authority".into(),
37 )),
38 }
39 }
40}