From 513705a7a8d5a069b8ebeabaf405f8def8e7d228 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 16 Apr 2023 01:19:24 +0000 Subject: feat: improve macro hygiene --- Cargo.toml | 2 +- README.md | 8 ++++---- src/response/macros.rs | 28 ++++++++++++++-------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8d1c4fb..9f5bade 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "windmark" -version = "0.3.4" +version = "0.3.5" authors = ["Fuwn "] edition = "2021" description = "An elegant and highly performant async Gemini server framework" diff --git a/README.md b/README.md index 3313b8f..a01b597 100644 --- a/README.md +++ b/README.md @@ -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") } }}; } -- cgit v1.2.3