lewp_css/domain/at_rules/media/
color_bit_depth.rs

1// This file is part of css. 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/css/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 css. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/css/master/COPYRIGHT.
3
4use {
5    crate::{
6        domain::{
7            expressions::CalculablePropertyValue,
8            numbers::CssUnsignedInteger,
9            units::Unit,
10        },
11        parsers::{Parse, ParserContext},
12        CustomParseError,
13    },
14    cssparser::{ParseError, Parser, ToCss},
15    std::fmt,
16};
17
18#[derive(Default, Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
19pub struct ColorBitDepth(CalculablePropertyValue<CssUnsignedInteger>);
20
21impl ToCss for ColorBitDepth {
22    fn to_css<W: fmt::Write>(&self, dest: &mut W) -> fmt::Result {
23        self.0.to_css(dest)
24    }
25}
26
27impl Parse for ColorBitDepth {
28    fn parse<'i, 't>(
29        context: &ParserContext,
30        input: &mut Parser<'i, 't>,
31    ) -> Result<Self, ParseError<'i, CustomParseError<'i>>> {
32        Ok(ColorBitDepth(
33            CssUnsignedInteger::parse_one_outside_calc_function(
34                context, input,
35            )?,
36        ))
37    }
38}