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