use derive_more::Display;
use std::fmt;
use crate::catalog::cutter::tables::CutterNumType;
#[derive(Display)]
#[display("{alpha_prefix}{numeric}")]
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize)]
pub struct CutterLoc {
alpha_prefix: char,
numeric: CutterNumType,
}
impl CutterLoc {
#[must_use]
pub fn new(alpha_prefix: char, numeric: CutterNumType) -> CutterLoc {
CutterLoc {
alpha_prefix,
numeric,
}
}
#[must_use]
pub fn alpha_prefix(&self) -> char {
self.alpha_prefix
}
#[must_use]
pub fn numeric(&self) -> CutterNumType {
self.numeric
}
}
#[derive(Display)]
#[display("{}{}{}", alpha_prefix, numeric, alpha_suffix.as_deref().unwrap_or(""))]
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize)]
pub struct CutterSanborn {
alpha_prefix: String,
numeric: CutterNumType,
alpha_suffix: Option<String>,
entry: &'static str,
}
impl CutterSanborn {
#[must_use]
pub fn new(
alpha_prefix: String,
numeric: CutterNumType,
alpha_suffix: Option<String>,
entry: &'static str,
) -> CutterSanborn {
CutterSanborn {
alpha_prefix,
numeric,
alpha_suffix,
entry,
}
}
#[must_use]
pub fn alpha_prefix(&self) -> &str {
&self.alpha_prefix
}
#[must_use]
pub fn alpha_suffix(&self) -> Option<&str> {
self.alpha_suffix.as_deref()
}
#[must_use]
pub fn numeric(&self) -> CutterNumType {
self.numeric
}
#[must_use]
pub fn entry(&self) -> &'static str {
self.entry
}
}
pub trait CutterType: fmt::Display {}
impl CutterType for CutterSanborn {}
impl CutterType for CutterLoc {}