webdav-serde 0.1.2

webdav-serde
Documentation
## webdav-serde

A Rust library for parsing and serializing WebDAV XML responses using `quick-xml` and `serde`.

## Features

- Parse WebDAV `multistatus` XML responses
- Serialize Rust structs to WebDAV XML format
- Support for all common WebDAV properties
- Helper methods for working with WebDAV responses

## Installation

Add this to your `Cargo.toml`:

```toml
[dependencies]
webdav-serde = "0.1.2"
```

## Usage

### Parsing WebDAV XML

```rust
use webdav_serde::Multistatus;

let xml = r#"<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:">
  <D:response>
    <D:href>/file.txt</D:href>
    <D:propstat>
      <D:prop>
        <D:getcontentlength>1024</D:getcontentlength>
        <D:getlastmodified>Mon, 13 Nov 2023 14:52:27 GMT</D:getlastmodified>
        <D:resourcetype></D:resourcetype>
      </D:prop>
      <D:status>HTTP/1.1 200 OK</D:status>
    </D:propstat>
  </D:response>
</D:multistatus>"#;

let multistatus = Multistatus::from_xml(xml).unwrap();

for response in &multistatus.response {
    println!("Path: {}", response.href);
    println!("Name: {}", response.name());
    println!("Is directory: {}", response.is_collection());
    
    if let Some(size) = response.propstat.prop.getcontentlength {
        println!("Size: {} bytes", size);
    }
}
```

### Command Line Tool

Parse WebDAV XML files from the command line:

```bash
cargo run -- xml/list.xml
```

This will display:
- Full parsed structure
- Summary of collections and files
- List of files with sizes

## Supported Properties

- `displayname` - Display name of the resource
- `creationdate` - Creation date
- `getcontentlength` - File size in bytes
- `getcontenttype` - MIME type
- `getetag` - Entity tag
- `getlastmodified` - Last modification date
- `lockdiscovery` - Lock information
- `resourcetype` - Resource type (collection or file)
- `supportedlock` - Supported lock types

## Examples

See the `xml/` directory for example WebDAV responses from different servers.

## License

MIT

```rust
use serde_xml_rs::from_str;
use webdav_serde::Multistatus;


fn main() {
    let src = include_str!("../xml/list.xml");
    let item: Multistatus = from_str(src).unwrap();
    println!("{:#?}", item);
}

```