webdav_methods/
lib.rs

1// SPDX-FileCopyrightText: d-k-bo <d-k-bo@mailbox.org>
2//
3// SPDX-License-Identifier: MIT OR Apache-2.0
4
5//! HTTP methods for WebDAV as defined in
6//! [RFC 4918][rfc].
7//!
8//! Unfortunately, the [`http`][http] crate
9//! [doesn't support creating custom `Method`s constants yet][http-pr],
10//! so they are currently defined as static variables using
11//! [`once_cell::sync::Lazy`][lazy].
12//!
13//! [rfc]: http://webdav.org/specs/rfc4918.html#http.methods.for.distributed.authoring
14//! [http]: https://docs.rs/http/latest/http/
15//! [http-pr]: https://github.com/hyperium/http/pull/595
16//! [lazy]: https://docs.rs/once_cell/latest/once_cell/sync/struct.Lazy.html
17
18use http::Method;
19use once_cell::sync::Lazy;
20
21macro_rules! method {
22    ($name:ident ) => {
23        #[doc = concat!(
24            "The `",
25            stringify!($name),
26            "` method as defined in [RFC 4918](http://webdav.org/specs/rfc4918.html#METHOD_",
27            stringify!($name),
28            ")."
29        )]
30        pub static $name: once_cell::sync::Lazy<Method> =
31            Lazy::new(|| Method::from_bytes(stringify!($name).as_bytes()).unwrap());
32    };
33}
34
35method!(PROPFIND);
36method!(PROPPATCH);
37method!(MKCOL);
38method!(COPY);
39method!(MOVE);
40method!(LOCK);
41method!(UNLOCK);