diff options
| author | Fuwn <[email protected]> | 2023-04-16 01:19:24 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-04-16 01:19:24 +0000 |
| commit | 513705a7a8d5a069b8ebeabaf405f8def8e7d228 (patch) | |
| tree | 6bbdf130ac4f4429c6501538c6b60e6a25c0b470 | |
| parent | refactor(hooks): implement call for hooks (diff) | |
| download | windmark-513705a7a8d5a069b8ebeabaf405f8def8e7d228.tar.xz windmark-513705a7a8d5a069b8ebeabaf405f8def8e7d228.zip | |
feat: improve macro hygiene
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | README.md | 8 | ||||
| -rw-r--r-- | src/response/macros.rs | 28 |
3 files changed, 19 insertions, 19 deletions
@@ -2,7 +2,7 @@ [package] name = "windmark" -version = "0.3.4" +version = "0.3.5" authors = ["Fuwn <[email protected]>"] edition = "2021" description = "An elegant and highly performant async Gemini server framework" @@ -18,18 +18,18 @@ Check out an example starter project # Cargo.toml [dependencies] -windmark = "0.3.4" +windmark = "0.3.5" tokio = { version = "1.26.0", features = ["full"] } # If you would like to use the built-in logger (recommended) -# windmark = { version = "0.3.4", features = ["logger"] } +# windmark = { version = "0.3.5", features = ["logger"] } # If you would like to use the built-in MIME dedection when `Success`-ing a file # (recommended) -# windmark = { version = "0.3.4", features = ["auto-deduce-mime"] } +# windmark = { version = "0.3.5", features = ["auto-deduce-mime"] } # If you would like to use macro-based responses (as seen below) -# windmark = { version = "0.3.4", features = ["response-macros"] } +# windmark = { version = "0.3.5", features = ["response-macros"] } ``` ### Implement a Windmark server diff --git a/src/response/macros.rs b/src/response/macros.rs index 1d13c8f..10f6b06 100644 --- a/src/response/macros.rs +++ b/src/response/macros.rs @@ -23,10 +23,10 @@ macro_rules! sync_response { #[macro_export] macro_rules! $name { ($body:expr /* $(,)? */) => { - |_: ::windmark::context::RouteContext| ::windmark::Response::$name($body) + |_: $crate::context::RouteContext| $crate::Response::$name($body) }; ($context:ident, $body:expr /* $(,)? */) => { - |$context: ::windmark::context::RouteContext| ::windmark::Response::$name($body) + |$context: $crate::context::RouteContext| $crate::Response::$name($body) }; } )* @@ -40,10 +40,10 @@ macro_rules! async_response { #[macro_export] macro_rules! [< $name _async >] { ($body:expr /* $(,)? */) => { - |_: ::windmark::context::RouteContext| async { ::windmark::Response::$name($body) } + |_: $crate::context::RouteContext| async { $crate::Response::$name($body) } }; ($context:ident, $body:expr /* $(,)? */) => { - |$context: ::windmark::context::RouteContext| async { ::windmark::Response::$name($body) } + |$context: $crate::context::RouteContext| async { $crate::Response::$name($body) } }; } })* @@ -86,8 +86,8 @@ response!(binary_success_auto); #[macro_export] macro_rules! binary_success { ($body:expr, $mime:expr) => { - |_: ::windmark::context::RouteContext| { - ::windmark::Response::binary_success($body, $mime) + |_: $crate::context::RouteContext| { + $crate::Response::binary_success($body, $mime) } }; ($body:expr) => {{ @@ -97,18 +97,18 @@ macro_rules! binary_success { feature to be enabled" ); - |_: ::windmark::context::RouteContext| { + |_: $crate::context::RouteContext| { #[cfg(feature = "auto-deduce-mime")] - return ::windmark::Response::binary_success_auto($body); + return $crate::Response::binary_success_auto($body); // Suppress item not found warning #[cfg(not(feature = "auto-deduce-mime"))] - ::windmark::Response::binary_success($body, "application/octet-stream") + $crate::Response::binary_success($body, "application/octet-stream") } }}; ($context:ident, $body:expr, $mime:expr) => { - |$context: ::windmark::context::RouteContext| { - ::windmark::Response::binary_success($body, $mime) + |$context: $crate::context::RouteContext| { + $crate::Response::binary_success($body, $mime) } }; ($context:ident, $body:expr) => {{ @@ -118,13 +118,13 @@ macro_rules! binary_success { feature to be enabled" ); - |$context: ::windmark::context::RouteContext| { + |$context: $crate::context::RouteContext| { #[cfg(feature = "auto-deduce-mime")] - return ::windmark::Response::binary_success_auto($body); + return $crate::Response::binary_success_auto($body); // Suppress item not found warning #[cfg(not(feature = "auto-deduce-mime"))] - ::windmark::Response::binary_success($body, "application/octet-stream") + $crate::Response::binary_success($body, "application/octet-stream") } }}; } |