Files
inbuxa-server/crates/dav-proto/src/responses/propstat.rs
T
jcoffey-dev 7dae9b29fd Import upstream v0.16.22, stripped
Upstream commit: 474dd0229cb20cf513036619781ed97bd8073c3f
Enterprise-only files removed or emptied: 63
Enterprise-only snippets removed: 117 in 50 files
Dangling module declarations removed: 5
Cargo edits turning enterprise off: 14
Verification: clean
Enterprise feature gates left for rebuilt features: 19 in 18 files

Produced by tools/fork/strip.py. The full report is in docs/fork/strip-reports/ on main.
2026-09-18 10:21:56 -07:00

75 lines
2.0 KiB
Rust

/*
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*/
use crate::schema::{
request::DavPropertyValue,
response::{Condition, List, Prop, PropStat, ResponseDescription, Status},
};
use hyper::StatusCode;
use std::fmt::Display;
impl Display for PropStat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "<D:propstat>")?;
self.prop.fmt(f)?;
self.status.fmt(f)?;
if let Some(error) = &self.error {
error.fmt(f)?;
}
if let Some(response_description) = &self.response_description {
response_description.fmt(f)?;
}
write!(f, "</D:propstat>")
}
}
impl Display for Prop {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "<D:prop>{}</D:prop>", self.0)
}
}
impl PropStat {
#[cfg(test)]
pub(crate) fn new(prop: impl Into<DavPropertyValue>) -> Self {
PropStat {
prop: Prop(List(vec![prop.into()])),
status: Status(StatusCode::OK),
error: None,
response_description: None,
}
}
pub fn new_list(props: Vec<DavPropertyValue>) -> Self {
PropStat {
prop: Prop(List(props)),
status: Status(StatusCode::OK),
error: None,
response_description: None,
}
}
pub fn with_prop(mut self, prop: impl Into<DavPropertyValue>) -> Self {
self.prop.0.0.push(prop.into());
self
}
pub fn with_status(mut self, status: StatusCode) -> Self {
self.status = Status(status);
self
}
pub fn with_error(mut self, error: impl Into<Condition>) -> Self {
self.error = Some(error.into());
self
}
pub fn with_response_description(mut self, response_description: impl Into<String>) -> Self {
self.response_description = Some(ResponseDescription(response_description.into()));
self
}
}