caniuse_serde/
Prefix.rs

1// This file is part of caniuse-serde. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/caniuse-serde/master/COPYRIGHT. No part of predicator, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
2// Copyright © 2017 The developers of caniuse-serde. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/caniuse-serde/master/COPYRIGHT.
3
4
5/// The prefix put before at-rules, property names and property values
6#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
7pub enum Prefix
8{
9	/// -o- prefix (legacy Opera Presto prefix).
10	o,
11	
12	/// -moz- prefix.
13	moz,
14	
15	/// -webkit- prefix (Is sometimes also used by IE, Edge and Blink-based browsers (Chrome and Opera)).
16	webkit,
17	
18	/// -ms- prefix.
19	ms,
20	
21	/// A prefix that did not exist in the caniuse.com data when this library was created
22	Unknown(String),
23}
24
25impl Default for Prefix
26{
27	/// Defaults to Prefix::webkit, the commonest prefix
28	#[inline(always)]
29	fn default() -> Self
30	{
31		Prefix::webkit
32	}
33}
34
35impl<'de> Deserialize<'de> for Prefix
36{
37	/// Deserialize using Serde
38	fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
39	{
40		match deserializer.deserialize_str(PrefixVisitor)?
41		{
42			None => Ok(Prefix::Unknown("".to_owned())),
43			Some(value) => Ok(value),
44		}
45	}
46}