#[non_exhaustive]
#[derive(Copy, Clone)]
pub enum Attribute {
Observable,
Interface(&'static str),
ResourceType(&'static str),
Title(&'static str),
Ct(u16), Sz(usize),
Other(&'static str),
}
impl Attribute {
pub fn write_link_format(&self, w: &mut impl core::fmt::Write) -> core::fmt::Result {
match self {
Attribute::Observable => write!(w, ";obs")?,
Attribute::ResourceType(s) => write!(w, ";rt=\"{s}\"")?,
Attribute::Interface(s) => write!(w, ";if=\"{s}\"")?,
Attribute::Title(s) => write!(w, ";title=\"{s}\"")?,
Attribute::Ct(s) => write!(w, ";ct={s}")?,
Attribute::Sz(s) => write!(w, ";sz={s}")?,
Attribute::Other(s) => write!(w, ";{s}")?,
}
Ok(())
}
}
pub trait Record {
type PathElement: AsRef<str>;
type PathElements: Iterator<Item = Self::PathElement>;
type Attributes: Iterator<Item = Attribute>;
fn path(&self) -> Self::PathElements;
fn rel(&self) -> Option<&str>;
fn attributes(&self) -> Self::Attributes;
}
pub trait Reporting {
type Record<'res>: Record
where
Self: 'res;
type Reporter<'res>: Iterator<Item = Self::Record<'res>>
where
Self: 'res;
fn report(&self) -> Self::Reporter<'_>;
#[inline]
#[allow(unused_variables, reason = "Names are part of user interface")]
fn write_extra_link_format(
&self,
writer: &mut impl core::fmt::Write,
is_first: &mut bool,
) -> core::fmt::Result {
Ok(())
}
}