ldp 0.1.0

A library to assist with the creation and maintenance of remote RDF data via LDP
use crate::vocab;
use oxigraph::model::NamedNodeRef;

/// The type of [Container](https://www.w3.org/TR/ldp/#ldpc).
#[derive(Clone, Debug)]
pub enum ContainerType {
    Basic,
    Direct,
    Indirect,
}

impl ContainerType {
    pub fn as_named_node_ref(&self) -> NamedNodeRef<'_> {
        match self {
            ContainerType::Basic => vocab::ldp::BASIC_CONTAINER,
            ContainerType::Direct => vocab::ldp::DIRECT_CONTAINER,
            ContainerType::Indirect => vocab::ldp::INDIRECT_CONTAINER,
        }
    }

    pub fn from_named_node_ref(node: NamedNodeRef<'_>) -> Option<Self> {
        match node {
            vocab::ldp::BASIC_CONTAINER => Some(ContainerType::Basic),
            vocab::ldp::DIRECT_CONTAINER => Some(ContainerType::Direct),
            vocab::ldp::INDIRECT_CONTAINER => Some(ContainerType::Indirect),
            _ => None,
        }
    }
}