use std::fmt;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct ProviderId(String);
impl ProviderId {
#[must_use]
pub fn new(value: impl Into<String>) -> Self {
Self(value.into())
}
#[must_use]
pub fn as_str(&self) -> &str {
&self.0
}
#[must_use]
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
}
impl AsRef<str> for ProviderId {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl From<String> for ProviderId {
fn from(value: String) -> Self {
Self::new(value)
}
}
impl From<&str> for ProviderId {
fn from(value: &str) -> Self {
Self::new(value)
}
}
impl fmt::Display for ProviderId {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(formatter)
}
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct ModelName(String);
impl ModelName {
#[must_use]
pub fn new(value: impl Into<String>) -> Self {
Self(value.into())
}
#[must_use]
pub fn as_str(&self) -> &str {
&self.0
}
#[must_use]
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
}
impl AsRef<str> for ModelName {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl From<String> for ModelName {
fn from(value: String) -> Self {
Self::new(value)
}
}
impl From<&str> for ModelName {
fn from(value: &str) -> Self {
Self::new(value)
}
}
impl fmt::Display for ModelName {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(formatter)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct RunId(uuid::Uuid);
impl RunId {
#[must_use]
pub fn new() -> Self {
Self(uuid::Uuid::new_v4())
}
#[must_use]
pub fn from_uuid(uuid: uuid::Uuid) -> Self {
Self(uuid)
}
#[must_use]
pub fn as_uuid(&self) -> &uuid::Uuid {
&self.0
}
}
impl Default for RunId {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for RunId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}