feat: add AppendCmd builder

This commit is contained in:
Michael Bøcker-Larsen 2020-12-17 00:41:26 +08:00
parent 469d338d5d
commit 24445c5c65
No known key found for this signature in database
GPG key ID: FEC5F9A03674F95A

View file

@ -93,6 +93,41 @@ pub struct AppendOptions<'a> {
pub date: Option<DateTime<FixedOffset>>,
}
/// A builder for the append command
#[derive(Default)]
pub struct AppendCmd<'a> {
flags: Vec<&'a Flag<'a>>,
date: Option<DateTime<FixedOffset>>,
}
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<FixedOffset>) -> &mut Self {
self.date = Some(date);
self
}
}
impl<'a> Into<AppendOptions<'a>> 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<T: Read + Write> Deref for Client<T> {