use std::ops::{Deref, DerefMut};
use disposition_model_common::{Id, IdInvalidFmt};
use serde::{Deserialize, Serialize};
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Clone, Debug, Hash, PartialEq, Eq, Deserialize, Serialize)]
pub struct NodeId(Id);
impl NodeId {
pub fn new(id: &'static str) -> Result<Self, IdInvalidFmt<'static>> {
Id::new(id).map(NodeId)
}
pub fn into_inner(self) -> Id {
self.0
}
}
impl From<Id> for NodeId {
fn from(id: Id) -> Self {
NodeId(id)
}
}
impl Deref for NodeId {
type Target = Id;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for NodeId {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}