#![allow(missing_docs)]
#[allow(unused_imports)]
use firkin_types::{ContainerId, InvalidContainerId};
#[cfg(test)]
#[allow(unused_imports)]
use std::io;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct PodId(ContainerId);
impl PodId {
pub fn new(id: impl Into<String>) -> std::result::Result<Self, InvalidContainerId> {
ContainerId::new(id).map(Self)
}
#[must_use]
pub fn as_str(&self) -> &str {
self.0.as_str()
}
}
impl std::fmt::Display for PodId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
impl IntoPodId for PodId {
fn into_pod_id(self) -> std::result::Result<PodId, InvalidContainerId> {
Ok(self)
}
}
pub trait IntoPodId {
fn into_pod_id(self) -> std::result::Result<PodId, InvalidContainerId>;
}
impl IntoPodId for &str {
fn into_pod_id(self) -> std::result::Result<PodId, InvalidContainerId> {
PodId::new(self)
}
}
impl IntoPodId for String {
fn into_pod_id(self) -> std::result::Result<PodId, InvalidContainerId> {
PodId::new(self)
}
}