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}
11
12impl Into<String> for Authority {
13 fn into(self) -> String {
14 match self {
15 Authority::Gpu => "Gpu".into(),
16 Authority::Audio => "Audio".into(),
17 Authority::Input => "Input".into(),
18 Authority::File => "File".into(),
19 }
20 }
21}
22
23impl TryInto<Authority> for String {
24 type Error = IntersticeAbiError;
25
26 fn try_into(self) -> Result<Authority, Self::Error> {
27 match self.as_str() {
28 "Gpu" => Ok(Authority::Gpu),
29 "Audio" => Ok(Authority::Audio),
30 "Input" => Ok(Authority::Input),
31 "File" => Ok(Authority::File),
32 _ => Err(IntersticeAbiError::ConversionError(
33 "Couldn't convert String to Authority".into(),
34 )),
35 }
36 }
37}