lewp_css/domain/at_rules/namespace/namespace_url.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::domain::Atom,
6 cssparser::ToCss,
7 precomputed_hash::PrecomputedHash,
8 std::{borrow::Borrow, fmt},
9};
10
11#[derive(Default, Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
12pub struct NamespaceUrl(pub Atom);
13
14impl ToCss for NamespaceUrl {
15 // https://drafts.csswg.org/cssom/#serialize-a-css-rule CSSNamespaceRule
16 fn to_css<W: fmt::Write>(&self, dest: &mut W) -> fmt::Result {
17 self.0.to_css(dest)
18 }
19}
20
21impl Borrow<str> for NamespaceUrl {
22 #[inline(always)]
23 fn borrow(&self) -> &str {
24 self.0.borrow()
25 }
26}
27
28impl PrecomputedHash for NamespaceUrl {
29 fn precomputed_hash(&self) -> u32 {
30 self.0.precomputed_hash()
31 }
32}