use twilight_model::channel::message::component::{Separator, SeparatorSpacingSize};
#[derive(Clone, Debug, Eq, PartialEq)]
#[must_use = "must be built into a separator"]
pub struct SeparatorBuilder(Separator);
impl SeparatorBuilder {
pub const fn new() -> Self {
Self(Separator {
id: None,
divider: None,
spacing: None,
})
}
pub const fn id(mut self, id: i32) -> Self {
self.0.id.replace(id);
self
}
pub const fn divider(mut self, divider: bool) -> Self {
self.0.divider.replace(divider);
self
}
pub const fn spacing(mut self, spacing: SeparatorSpacingSize) -> Self {
self.0.spacing.replace(spacing);
self
}
pub const fn build(self) -> Separator {
self.0
}
}
impl Default for SeparatorBuilder {
fn default() -> Self {
Self::new()
}
}
impl From<SeparatorBuilder> for Separator {
fn from(builder: SeparatorBuilder) -> Self {
builder.build()
}
}
#[cfg(test)]
mod tests {
use super::*;
use static_assertions::assert_impl_all;
use std::fmt::Debug;
assert_impl_all!(SeparatorBuilder: Clone, Debug, Eq, PartialEq, Send, Sync);
assert_impl_all!(Separator: From<SeparatorBuilder>);
#[test]
fn builder() {
let expected = Separator {
id: None,
divider: None,
spacing: None,
};
let actual = SeparatorBuilder::new().build();
assert_eq!(actual, expected);
}
}