implement sync multistatus extension
This commit is contained in:
parent
410d663a5e
commit
171a762768
4 changed files with 63 additions and 1 deletions
|
@ -74,7 +74,7 @@ impl dav::Extension for All {
|
||||||
type ResourceType = ResourceType;
|
type ResourceType = ResourceType;
|
||||||
type ReportType = ReportType<All>;
|
type ReportType = ReportType<All>;
|
||||||
type ReportTypeName = ReportTypeName;
|
type ReportTypeName = ReportTypeName;
|
||||||
type Multistatus = Disabled;
|
type Multistatus = Multistatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
|
@ -236,3 +236,25 @@ impl xml::QWrite for ReportTypeName {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
|
pub enum Multistatus {
|
||||||
|
Sync(sync::Multistatus),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl xml::QWrite for Multistatus {
|
||||||
|
async fn qwrite(
|
||||||
|
&self,
|
||||||
|
xml: &mut xml::Writer<impl xml::IWrite>,
|
||||||
|
) -> Result<(), quick_xml::Error> {
|
||||||
|
match self {
|
||||||
|
Self::Sync(s) => s.qwrite(xml).await,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl xml::QRead<Multistatus> for Multistatus {
|
||||||
|
async fn qread(xml: &mut xml::Reader<impl xml::IRead>) -> Result<Self, error::ParsingError> {
|
||||||
|
sync::Multistatus::qread(xml).await.map(Self::Sync)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,14 @@ impl QRead<ReportTypeName> for ReportTypeName {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl QRead<Multistatus> for Multistatus {
|
||||||
|
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
|
||||||
|
SyncToken::qread(xml)
|
||||||
|
.await
|
||||||
|
.map(|sync_token| Multistatus { sync_token })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<E: dav::Extension> QRead<SyncCollection<E>> for SyncCollection<E> {
|
impl<E: dav::Extension> QRead<SyncCollection<E>> for SyncCollection<E> {
|
||||||
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
|
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
|
||||||
xml.open(DAV_URN, "sync-collection").await?;
|
xml.open(DAV_URN, "sync-collection").await?;
|
||||||
|
@ -80,6 +88,7 @@ impl QRead<SyncTokenRequest> for SyncTokenRequest {
|
||||||
|
|
||||||
impl QRead<SyncToken> for SyncToken {
|
impl QRead<SyncToken> for SyncToken {
|
||||||
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
|
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
|
||||||
|
println!("sync_token {:?}", xml.peek());
|
||||||
xml.open(DAV_URN, "sync-token").await?;
|
xml.open(DAV_URN, "sync-token").await?;
|
||||||
let token = xml.tag_string().await?;
|
let token = xml.tag_string().await?;
|
||||||
xml.close().await?;
|
xml.close().await?;
|
||||||
|
|
|
@ -32,6 +32,12 @@ impl QWrite for ReportTypeName {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl QWrite for Multistatus {
|
||||||
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
|
self.sync_token.qwrite(xml).await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<E: Extension> QWrite for SyncCollection<E> {
|
impl<E: Extension> QWrite for SyncCollection<E> {
|
||||||
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
|
||||||
let start = xml.create_dav_element("sync-collection");
|
let start = xml.create_dav_element("sync-collection");
|
||||||
|
@ -196,4 +202,24 @@ mod tests {
|
||||||
]))
|
]))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn multistatus_ext() {
|
||||||
|
serialize_deserialize(&dav::Multistatus::<All> {
|
||||||
|
responses: vec![dav::Response {
|
||||||
|
status_or_propstat: dav::StatusOrPropstat::Status(
|
||||||
|
vec![dav::Href("/".into())],
|
||||||
|
dav::Status(http::status::StatusCode::OK),
|
||||||
|
),
|
||||||
|
error: None,
|
||||||
|
location: None,
|
||||||
|
responsedescription: None,
|
||||||
|
}],
|
||||||
|
responsedescription: None,
|
||||||
|
extension: Some(realization::Multistatus::Sync(Multistatus {
|
||||||
|
sync_token: SyncToken("http://example.com/ns/sync/1232".into()),
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,11 @@ pub enum ReportTypeName {
|
||||||
SyncCollection,
|
SyncCollection,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
|
pub struct Multistatus {
|
||||||
|
pub sync_token: SyncToken,
|
||||||
|
}
|
||||||
|
|
||||||
//@FIXME add SyncToken to Multistatus
|
//@FIXME add SyncToken to Multistatus
|
||||||
|
|
||||||
/// Name: sync-collection
|
/// Name: sync-collection
|
||||||
|
|
Loading…
Reference in a new issue