Complete implementation (untested) except SearchSnippet and EventSource.

This commit is contained in:
Mauro D
2022-05-11 16:52:35 +00:00
parent 17cecbdb63
commit e10834ecaa
31 changed files with 1540 additions and 166 deletions

View File

@@ -9,6 +9,9 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VacationResponse<State = Get> {
#[serde(skip)]
_create_id: Option<usize>,
#[serde(skip)]
_state: std::marker::PhantomData<State>,

View File

@@ -1,42 +1,46 @@
use crate::{core::set::from_timestamp, Set};
use crate::{
core::set::{from_timestamp, Create},
Set,
};
use super::VacationResponse;
impl VacationResponse<Set> {
pub fn is_enabled(mut self, is_enabled: bool) -> Self {
pub fn is_enabled(&mut self, is_enabled: bool) -> &mut Self {
self.is_enabled = Some(is_enabled);
self
}
pub fn from_date(mut self, from_date: Option<i64>) -> Self {
pub fn from_date(&mut self, from_date: Option<i64>) -> &mut Self {
self.from_date = from_date.map(from_timestamp);
self
}
pub fn to_date(mut self, to_date: Option<i64>) -> Self {
pub fn to_date(&mut self, to_date: Option<i64>) -> &mut Self {
self.to_date = to_date.map(from_timestamp);
self
}
pub fn subject(mut self, subject: Option<String>) -> Self {
self.subject = subject;
pub fn subject(&mut self, subject: Option<impl Into<String>>) -> &mut Self {
self.subject = subject.map(|s| s.into());
self
}
pub fn text_body(mut self, text_body: Option<String>) -> Self {
self.text_body = text_body;
pub fn text_body(&mut self, text_body: Option<impl Into<String>>) -> &mut Self {
self.text_body = text_body.map(|s| s.into());
self
}
pub fn html_body(mut self, html_body: Option<String>) -> Self {
self.html_body = html_body;
pub fn html_body(&mut self, html_body: Option<impl Into<String>>) -> &mut Self {
self.html_body = html_body.map(|s| s.into());
self
}
}
impl VacationResponse {
pub fn new() -> VacationResponse<Set> {
impl Create for VacationResponse<Set> {
fn new(_create_id: Option<usize>) -> Self {
VacationResponse {
_create_id,
_state: Default::default(),
id: None,
is_enabled: None,
@@ -47,4 +51,8 @@ impl VacationResponse {
html_body: "".to_string().into(),
}
}
fn create_id(&self) -> Option<String> {
self._create_id.map(|id| format!("c{}", id))
}
}