use std::fmt;
use uuid::Uuid;
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct SubscriptionId(pub String);
impl fmt::Display for SubscriptionId {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "{}", self.0)
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct PartitionId(pub String);
impl fmt::Display for PartitionId {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "{}", self.0)
}
}
#[derive(Clone, Debug)]
pub struct StreamId(pub String);
impl StreamId {
pub fn new<T: Into<String>>(id: T) -> Self {
StreamId(id.into())
}
}
impl fmt::Display for StreamId {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "{}", self.0)
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct FlowId(pub String);
impl FlowId {
pub fn new<T: Into<String>>(id: T) -> Self {
FlowId(id.into())
}
}
impl fmt::Display for FlowId {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "{}", self.0)
}
}
impl Default for FlowId {
fn default() -> FlowId {
FlowId(Uuid::new_v4().to_string())
}
}
#[derive(Clone, Debug)]
pub struct BatchCommitData<'a> {
pub stream_id: StreamId,
pub cursor: &'a [u8],
}
#[derive(Clone, Debug)]
pub struct EventType<'a>(pub &'a str);
impl<'a> EventType<'a> {
pub fn new(value: &'a str) -> EventType {
EventType(value)
}
}