use alloc::boxed::Box;
use alloc::string::String;
use core::fmt;
use crate::node::Data;
#[derive(Clone, Debug)]
pub(crate) struct RootState;
impl RootState {
pub(crate) const fn new() -> Self {
Self
}
}
impl fmt::Display for RootState {
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
Ok(())
}
}
#[derive(Clone, Debug)]
pub(crate) struct StaticState {
pub prefix: Box<[u8]>,
}
impl StaticState {
pub(crate) fn new(prefix: &[u8]) -> Self {
Self {
prefix: prefix.into(),
}
}
}
impl fmt::Display for StaticState {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", String::from_utf8_lossy(&self.prefix))
}
}
#[derive(Clone, Debug)]
pub(crate) struct DynamicState {
pub name: Box<str>,
}
impl DynamicState {
pub(crate) fn new(name: &str) -> Self {
Self { name: name.into() }
}
}
impl fmt::Display for DynamicState {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "<{}>", self.name)
}
}
#[derive(Clone, Debug)]
pub(crate) struct WildcardState {
pub name: Box<str>,
}
impl WildcardState {
pub(crate) fn new(name: &str) -> Self {
Self { name: name.into() }
}
}
impl fmt::Display for WildcardState {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "<*{}>", self.name)
}
}
#[derive(Clone, Debug)]
pub(crate) struct EndWildcardState<T> {
pub name: Box<str>,
pub data: Data<T>,
}
impl<T> EndWildcardState<T> {
pub(crate) fn new(name: &str, data: Data<T>) -> Self {
Self {
name: name.into(),
data,
}
}
}
impl<T> fmt::Display for EndWildcardState<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "<*{}>", self.name)
}
}