kvapi_macros_internals/api/
common.rs1use std::collections::HashSet;
2use syn::{
3 parse::{Parse, ParseStream},
4 Token,
5};
6
7#[derive(Debug, PartialEq)]
9pub enum Separator {
10 Colon,
11 Equals,
12 Arrow,
13}
14
15impl Parse for Separator {
16 fn parse(input: ParseStream) -> syn::Result<Self> {
17 if input.peek(Token![:]) {
18 input.parse::<Token![:]>()?;
19 Ok(Self::Colon)
20 } else if input.peek(Token![=]) {
21 input.parse::<Token![=]>()?;
22 Ok(Self::Equals)
23 } else if input.peek(Token![->]) {
24 input.parse::<Token![->]>()?;
25 Ok(Self::Arrow)
26 } else {
27 Err(syn::Error::new(
28 input.span(),
29 "expected one of ':', '=', or '->'",
30 ))
31 }
32 }
33}
34
35pub fn file_types() -> HashSet<&'static str> {
37 let mut set: HashSet<&str> = HashSet::new();
38 vec!["json", "csv", "xml", "toml", "yaml", "html", "htm"]
39 .iter()
40 .for_each(|file_type| {
41 set.insert(file_type);
42 });
43 set
44}