1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#![allow(non_upper_case_globals)]
use bitflags::bitflags;
use crate::traits::ToCss;
use crate::printer::Printer;
use crate::error::PrinterError;
bitflags! {
pub struct VendorPrefix: u8 {
const None = 0b00000001;
const WebKit = 0b00000010;
const Moz = 0b00000100;
const Ms = 0b00001000;
const O = 0b00010000;
}
}
impl Default for VendorPrefix {
fn default() -> VendorPrefix {
VendorPrefix::None
}
}
impl VendorPrefix {
pub fn from_str(s: &str) -> VendorPrefix {
match s {
"webkit" => VendorPrefix::WebKit,
"moz" => VendorPrefix::Moz,
"ms" => VendorPrefix::Ms,
"o" => VendorPrefix::O,
_ => unreachable!()
}
}
}
impl ToCss for VendorPrefix {
fn to_css<W>(&self, dest: &mut Printer<W>) -> Result<(), PrinterError> where W: std::fmt::Write {
match *self {
VendorPrefix::WebKit => dest.write_str("-webkit-"),
VendorPrefix::Moz => dest.write_str("-moz-"),
VendorPrefix::Ms => dest.write_str("-ms-"),
VendorPrefix::O => dest.write_str("-o-"),
_ => Ok(())
}
}
}