use std::fmt;
use uuid::Uuid;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct WorkflowConversationId(Uuid);
impl WorkflowConversationId {
#[must_use]
pub const fn from_bytes(bytes: [u8; 16]) -> Self {
Self(Uuid::from_bytes(bytes))
}
#[must_use]
pub const fn to_bytes(self) -> [u8; 16] {
*self.0.as_bytes()
}
pub(crate) const fn from_uuid(id: Uuid) -> Self {
Self(id)
}
pub(crate) const fn as_uuid(self) -> Uuid {
self.0
}
}
impl fmt::Display for WorkflowConversationId {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(formatter)
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct WorkflowRunId(Uuid);
impl WorkflowRunId {
#[must_use]
pub const fn from_bytes(bytes: [u8; 16]) -> Self {
Self(Uuid::from_bytes(bytes))
}
#[must_use]
pub const fn to_bytes(self) -> [u8; 16] {
*self.0.as_bytes()
}
pub(crate) const fn from_uuid(id: Uuid) -> Self {
Self(id)
}
pub(crate) const fn as_uuid(self) -> Uuid {
self.0
}
}
impl fmt::Display for WorkflowRunId {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(formatter)
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct WorkflowIdentity {
pub conversation: WorkflowConversationId,
pub run: WorkflowRunId,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct WorkflowStepId(u64);
impl WorkflowStepId {
#[must_use]
pub const fn position(self) -> u64 {
self.0
}
pub(crate) const fn from_position(position: u64) -> Self {
Self(position)
}
}
impl fmt::Display for WorkflowStepId {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "step:{}", self.0)
}
}