#[allow(clippy::wildcard_imports)]
use super::*;
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(try_from = "String", into = "String")]
pub struct ProjectId(pub(super) String);
impl StableId for ProjectId {
const PREFIX: &'static str = "p-";
const LABEL: &'static str = "project id";
const ARTICLE: &'static str = "a";
fn from_validated(raw: String) -> Self {
Self(raw)
}
fn as_str(&self) -> &str {
&self.0
}
}
impl ProjectId {
pub const MAX_LEN: usize = <Self as StableId>::MAX_LEN;
pub fn new(raw: &str) -> Result<Self> {
<Self as StableId>::new(raw)
}
#[must_use]
pub fn generate() -> Self {
<Self as StableId>::generate()
}
#[must_use]
pub fn as_str(&self) -> &str {
<Self as StableId>::as_str(self)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(try_from = "String", into = "String")]
pub struct EpicId(pub(super) String);
impl StableId for EpicId {
const PREFIX: &'static str = "e-";
const LABEL: &'static str = "epic id";
const ARTICLE: &'static str = "an";
fn from_validated(raw: String) -> Self {
Self(raw)
}
fn as_str(&self) -> &str {
&self.0
}
}
impl EpicId {
pub const MAX_LEN: usize = <Self as StableId>::MAX_LEN;
pub fn new(raw: &str) -> Result<Self> {
<Self as StableId>::new(raw)
}
#[must_use]
pub fn generate() -> Self {
<Self as StableId>::generate()
}
#[must_use]
pub fn as_str(&self) -> &str {
<Self as StableId>::as_str(self)
}
}
impl std::fmt::Display for ProjectId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.0)
}
}
impl TryFrom<String> for ProjectId {
type Error = TixError;
fn try_from(raw: String) -> Result<Self> {
Self::new(&raw)
}
}
impl std::fmt::Display for EpicId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.0)
}
}
impl TryFrom<String> for EpicId {
type Error = TixError;
fn try_from(raw: String) -> Result<Self> {
Self::new(&raw)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(try_from = "String", into = "String")]
pub struct InitiativeId(pub(super) String);
impl StableId for InitiativeId {
const PREFIX: &'static str = "i-";
const LABEL: &'static str = "initiative id";
const ARTICLE: &'static str = "an";
fn from_validated(raw: String) -> Self {
Self(raw)
}
fn as_str(&self) -> &str {
&self.0
}
}
impl InitiativeId {
pub const MAX_LEN: usize = <Self as StableId>::MAX_LEN;
pub fn new(raw: &str) -> Result<Self> {
<Self as StableId>::new(raw)
}
#[must_use]
pub fn generate() -> Self {
<Self as StableId>::generate()
}
#[must_use]
pub fn as_str(&self) -> &str {
<Self as StableId>::as_str(self)
}
}
impl std::fmt::Display for InitiativeId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.0)
}
}
impl TryFrom<String> for InitiativeId {
type Error = TixError;
fn try_from(raw: String) -> Result<Self> {
Self::new(&raw)
}
}
pub(super) fn is_structural_key_char(c: char) -> bool {
c.is_whitespace()
|| matches!(c, '.' | '"' | '\'' | '[' | ']' | '#' | '=' | '\\')
|| c.is_control()
}