From 24445c5c652b6098d8c859411da74264105506dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20B=C3=B8cker-Larsen?= Date: Thu, 17 Dec 2020 00:41:26 +0800 Subject: [PATCH] feat: add AppendCmd builder --- src/client.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/client.rs b/src/client.rs index 167ea70..1e33ab5 100644 --- a/src/client.rs +++ b/src/client.rs @@ -93,6 +93,41 @@ pub struct AppendOptions<'a> { pub date: Option>, } +/// A builder for the append command +#[derive(Default)] +pub struct AppendCmd<'a> { + flags: Vec<&'a Flag<'a>>, + date: Option>, +} + +impl<'a> AppendCmd<'a> { + /// Create a new AppendCmd builder + pub fn create() -> Self { + Self::default() + } + + /// Append a flag + pub fn flag(&mut self, flag: &'a Flag<'a>) -> &mut Self { + self.flags.push(flag); + self + } + + /// Set the internal date + pub fn internal_date(&mut self, date: DateTime) -> &mut Self { + self.date = Some(date); + self + } +} + +impl<'a> Into> for AppendCmd<'a> { + fn into(self) -> AppendOptions<'a> { + AppendOptions { + flags: Some(&self.flags[..]), + date: self.date, + } + } +} + // `Deref` instances are so we can make use of the same underlying primitives in `Client` and // `Session` impl Deref for Client {