/* * SPDX-FileCopyrightText: 2020 Stalwart Labs LLC * * SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL */ use crate::schema::{ Namespace, Namespaces, response::{List, MkColResponse, PropStat}, }; use std::fmt::Display; impl Display for MkColResponse { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "")?; if !self.mkcalendar { write!( f, "{}", self.namespaces, self.propstat ) } else { write!( f, "{}", self.namespaces, self.propstat ) } } } impl MkColResponse { pub fn new(propstat: Vec) -> Self { Self { namespaces: Namespaces::default(), propstat: List(propstat), mkcalendar: false, } } pub fn with_mkcalendar(mut self, mkcalendar: bool) -> Self { self.mkcalendar = mkcalendar; if mkcalendar { self.namespaces.set(Namespace::CalDav); } self } pub fn with_namespace(mut self, namespace: Namespace) -> Self { self.namespaces.set(namespace); self } }