mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-02 14:18:49 +00:00
feat: xrservicetype to/from string and iter
This commit is contained in:
parent
940d9c9dc8
commit
e2a76133d6
1 changed files with 24 additions and 1 deletions
|
@ -4,7 +4,7 @@ use crate::{
|
|||
};
|
||||
use expect_dialog::ExpectDialog;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{collections::HashMap, fmt::Display, fs::File, io::BufReader};
|
||||
use std::{collections::HashMap, fmt::Display, fs::File, io::BufReader, slice::Iter};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum XRServiceType {
|
||||
|
@ -12,6 +12,29 @@ pub enum XRServiceType {
|
|||
Wivrn,
|
||||
}
|
||||
|
||||
impl XRServiceType {
|
||||
pub fn from_string(s: String) -> Self {
|
||||
match s.trim().to_lowercase().as_str() {
|
||||
"monado" => Self::Monado,
|
||||
"wivrn" => Self::Wivrn,
|
||||
_ => Self::Monado,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn iter() -> Iter<'static, XRServiceType> {
|
||||
[Self::Monado, Self::Wivrn].iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for XRServiceType {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str(match self {
|
||||
Self::Monado => "Monado",
|
||||
Self::Wivrn => "WiVRn",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Profile {
|
||||
pub name: String,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue