#[derive(Debug, Clone)]
pub enum Partition {
Key(String),
Id(String),
}
#[derive(Debug, Clone, Default)]
pub struct SendEventOptions {
pub partition: Option<Partition>,
}
impl SendEventOptions {
pub fn new() -> Self {
Self::default()
}
pub fn with_partition_key(mut self, partition_key: impl Into<String>) -> Self {
self.partition = Some(Partition::Key(partition_key.into()));
self
}
pub fn with_partition_id(mut self, partition_id: impl Into<String>) -> Self {
self.partition = Some(Partition::Id(partition_id.into()));
self
}
pub fn partition_key(&self) -> Option<&str> {
match &self.partition {
Some(Partition::Key(key)) => Some(key),
_ => None,
}
}
pub fn partition_id(&self) -> Option<&str> {
match &self.partition {
Some(Partition::Id(id)) => Some(id),
_ => None,
}
}
pub fn into_partition_key(self) -> Option<String> {
match self.partition {
Some(Partition::Key(key)) => Some(key),
_ => None,
}
}
pub fn into_partition_id(self) -> Option<String> {
match self.partition {
Some(Partition::Id(id)) => Some(id),
_ => None,
}
}
}