switchyard_protocol/
category.rs1use std::{collections::HashMap, str::FromStr};
7
8use crate::ModelId;
9
10#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
12pub enum Category {
13 Any,
15 Capable,
17 Efficient,
19 Judge,
21}
22
23impl Category {
24 pub fn to_map(category: Category, names: &[&str]) -> HashMap<Category, Vec<ModelId>> {
26 [(
27 category,
28 names.iter().map(|name| ModelId::from(*name)).collect(),
29 )]
30 .into()
31 }
32}
33
34impl FromStr for Category {
35 type Err = String;
36 fn from_str(s: &str) -> Result<Self, Self::Err> {
37 let c = match s {
38 "capable" => Self::Capable,
39 "efficient" => Self::Efficient,
40 "judge" => Self::Judge,
41 "any" => Self::Any,
42 x => {
43 return Err(format!("Invalid Category '{x}'"));
44 }
45 };
46 Ok(c)
47 }
48}