hook resource type
This commit is contained in:
parent
929a185f37
commit
c52a659151
3 changed files with 27 additions and 5 deletions
|
@ -23,6 +23,10 @@ impl Context for CalExtension {
|
||||||
async fn hook_property(&self, prop: &Self::Property, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError> {
|
async fn hook_property(&self, prop: &Self::Property, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError> {
|
||||||
prop.write(xml, self.child()).await
|
prop.write(xml, self.child()).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn hook_resourcetype(&self, restype: &Self::ResourceType, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError> {
|
||||||
|
restype.write(xml, self.child()).await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CalExtension {
|
impl CalExtension {
|
||||||
|
@ -58,7 +62,13 @@ impl QuickWritable<CalExtension> for Property {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl QuickWritable<CalExtension> for ResourceType {
|
||||||
|
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: CalExtension) -> Result<(), QError> {
|
||||||
|
match self {
|
||||||
|
Self::Calendar => xml.write_event_async(Event::Empty(ctx.create_dav_element("calendar"))).await,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
|
@ -8,7 +8,7 @@ impl Extension for CalExtension {
|
||||||
type Error = Violation;
|
type Error = Violation;
|
||||||
type Property = Property;
|
type Property = Property;
|
||||||
type PropertyRequest = Property; //@FIXME
|
type PropertyRequest = Property; //@FIXME
|
||||||
type ResourceType = Property; //@FIXME
|
type ResourceType = ResourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Violation {
|
pub enum Violation {
|
||||||
|
@ -34,3 +34,7 @@ pub enum Property {
|
||||||
CalendarDescription,
|
CalendarDescription,
|
||||||
CalendarTimezone,
|
CalendarTimezone,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum ResourceType {
|
||||||
|
Calendar,
|
||||||
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ pub trait Context: Extension {
|
||||||
fn create_dav_element(&self, name: &str) -> BytesStart;
|
fn create_dav_element(&self, name: &str) -> BytesStart;
|
||||||
async fn hook_error(&self, err: &Self::Error, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError>;
|
async fn hook_error(&self, err: &Self::Error, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError>;
|
||||||
async fn hook_property(&self, prop: &Self::Property, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError>;
|
async fn hook_property(&self, prop: &Self::Property, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError>;
|
||||||
|
async fn hook_resourcetype(&self, prop: &Self::ResourceType, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// -------------- NoExtension Encoding Context
|
/// -------------- NoExtension Encoding Context
|
||||||
|
@ -41,6 +42,9 @@ impl Context for NoExtension {
|
||||||
async fn hook_property(&self, prop: &Disabled, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError> {
|
async fn hook_property(&self, prop: &Disabled, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError> {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
async fn hook_resourcetype(&self, restype: &Disabled, xml: &mut Writer<impl AsyncWrite+Unpin>) -> Result<(), QError> {
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -320,13 +324,17 @@ impl<C: Context> QuickWritable<C> for Property<C> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: Context> QuickWritable<C> for ActiveLock {
|
impl<C: Context> QuickWritable<C> for ResourceType<C> {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
||||||
unimplemented!();
|
match self {
|
||||||
|
Self::Collection => xml.write_event_async(Event::Empty(ctx.create_dav_element("collection"))).await?,
|
||||||
|
Self::Extension(inner) => ctx.hook_resourcetype(inner, xml).await?,
|
||||||
|
};
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: Context> QuickWritable<C> for ResourceType<C> {
|
impl<C: Context> QuickWritable<C> for ActiveLock {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue