lewp_css/domain/at_rules/font_feature_values/
declaration.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 {crate::domain::Atom, cssparser::ToCss, std::fmt};
5
6/// A @font-feature-values block declaration.
7/// It is `<ident>: <integer>+`.
8/// This struct can take 3 value types.
9/// - `SingleValue` is to keep just one unsigned integer value.
10/// - `PairValues` is to keep one or two unsigned integer values.
11/// - `VectorValues` is to keep a list of unsigned integer values.
12#[derive(Clone, Debug, PartialEq)]
13pub struct FontFeatureValuesDeclaration<T: ToCss> {
14    /// An `<ident>` for declaration name.
15    pub name: Atom,
16
17    /// An `<integer>+` for declaration value.
18    pub value: T,
19}
20
21impl<T: ToCss> ToCss for FontFeatureValuesDeclaration<T> {
22    #[inline(always)]
23    fn to_css<W: fmt::Write>(&self, dest: &mut W) -> fmt::Result {
24        self.to_css_without_trailing_semicolon(dest)?;
25        dest.write_char(';')
26    }
27}
28
29impl<T: ToCss> FontFeatureValuesDeclaration<T> {
30    #[inline(always)]
31    pub(crate) fn to_css_without_trailing_semicolon<W: fmt::Write>(
32        &self,
33        dest: &mut W,
34    ) -> fmt::Result {
35        self.name.to_css(dest)?;
36        dest.write_char(':')?;
37        self.value.to_css(dest)
38    }
39}