1#![no_std]
4#![forbid(unsafe_code)]
5
6mod list;
7
8#[cfg(feature = "helpers")]
9use core::str;
10
11pub use psl_types::{Domain, Info, List as Psl, Suffix, Type};
12
13pub struct List;
15
16impl Psl for List {
17 #[inline]
18 fn find<'a, T>(&self, labels: T) -> Info
19 where
20 T: Iterator<Item = &'a [u8]>,
21 {
22 list::lookup(labels)
23 }
24}
25
26#[cfg(feature = "helpers")]
28#[inline]
29pub fn suffix(name: &[u8]) -> Option<Suffix<'_>> {
30 List.suffix(name)
31}
32
33#[cfg(feature = "helpers")]
35#[inline]
36pub fn suffix_str(name: &str) -> Option<&str> {
37 let bytes = suffix(name.as_bytes())?.trim().as_bytes();
38 str::from_utf8(bytes).ok()
39}
40
41#[cfg(feature = "helpers")]
43#[inline]
44pub fn domain(name: &[u8]) -> Option<Domain<'_>> {
45 List.domain(name)
46}
47
48#[cfg(feature = "helpers")]
50#[inline]
51pub fn domain_str(name: &str) -> Option<&str> {
52 let bytes = domain(name.as_bytes())?.trim().as_bytes();
53 str::from_utf8(bytes).ok()
54}