Skip to content

Commit

Permalink
feat: improve macro hygiene
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuwn committed Apr 16, 2023
1 parent c7f01aa commit 7925d9b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[package]
name = "windmark"
version = "0.3.4"
version = "0.3.5"
authors = ["Fuwn <contact@fuwn.me>"]
edition = "2021"
description = "An elegant and highly performant async Gemini server framework"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 14 additions & 14 deletions src/response/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
}
)*
Expand All @@ -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) }
};
}
})*
Expand Down Expand Up @@ -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) => {{
Expand All @@ -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) => {{
Expand All @@ -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")
}
}};
}

0 comments on commit 7925d9b

Please sign in to comment.