css_ast/functions/
symbols_function.rs1use bumpalo::collections::Vec;
2use css_parse::{Function, T, function_set, keyword_set};
3use csskit_derives::{Parse, Peek, ToCursors, ToSpan, Visitable};
4
5use crate::types::Image;
6
7function_set!(pub struct SymbolsFunctionName "symbols");
8
9#[derive(Parse, Peek, ToCursors, ToSpan, Visitable, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
15#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
16#[visit]
17pub struct SymbolsFunction<'a>(Function<SymbolsFunctionName, (Option<SymbolsType>, Vec<'a, Symbol<'a>>)>);
18
19keyword_set!(
20 #[derive(Visitable)]
26 #[visit(skip)]
27 pub enum SymbolsType {
28 Cyclic: "cyclic",
29 Numeric: "numeric",
30 Alphabetic: "alphabetic",
31 Symbolic: "symbolic",
32 Fixed: "fixed",
33 }
34);
35
36#[derive(Parse, Peek, ToCursors, ToSpan, Visitable, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
44#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
45#[allow(clippy::large_enum_variant)] #[visit(children)]
47pub enum Symbol<'a> {
48 #[visit(skip)]
49 String(T![String]),
50 Image(Image<'a>),
51}
52
53#[cfg(test)]
54mod tests {
55 use super::*;
56 use css_parse::assert_parse;
57
58 #[test]
59 fn size_test() {
60 assert_eq!(std::mem::size_of::<SymbolsFunction>(), 80);
61 assert_eq!(std::mem::size_of::<Symbol>(), 216);
62 assert_eq!(std::mem::size_of::<SymbolsType>(), 16);
63 }
64
65 #[test]
66 fn test_writes() {
67 assert_parse!(SymbolsFunction, "symbols(symbolic'+')");
68 assert_parse!(SymbolsFunction, "symbols(symbolic'*''†''‡')");
69 }
70}