aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-01-12 16:14:27 +0000
committerFuwn <[email protected]>2026-01-12 16:14:27 +0000
commitec1bd9d70cfb9dc4bd793e074c105d49c9742c0c (patch)
tree47a9af3d503256194b08f4318b9601db3156c5c5 /src
parentchore: Increment minor version (diff)
downloadwindmark-ec1bd9d70cfb9dc4bd793e074c105d49c9742c0c.tar.xz
windmark-ec1bd9d70cfb9dc4bd793e074c105d49c9742c0c.zip
refactor(response): Optimise response building
Diffstat (limited to 'src')
-rw-r--r--src/response.rs25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/response.rs b/src/response.rs
index 853bfec..8e3fa87 100644
--- a/src/response.rs
+++ b/src/response.rs
@@ -76,11 +76,14 @@ impl Response {
#[allow(clippy::needless_pass_by_value)]
pub fn success(content: impl ToString) -> Self {
- Self::new(20, content.to_string())
+ let mut response = Self::new(20, content.to_string());
+
+ response
.with_mime("text/gemini")
.with_languages(["en"])
- .with_character_set("utf-8")
- .clone()
+ .with_character_set("utf-8");
+
+ response
}
#[must_use]
@@ -88,17 +91,21 @@ impl Response {
content: impl AsRef<[u8]>,
mime: impl Into<String> + AsRef<str>,
) -> Self {
- Self::new(21, String::from_utf8_lossy(content.as_ref()))
- .with_mime(mime)
- .clone()
+ let mut response = Self::new(21, String::from_utf8_lossy(content.as_ref()));
+
+ response.with_mime(mime);
+
+ response
}
#[cfg(feature = "auto-deduce-mime")]
#[must_use]
pub fn binary_success_auto(content: &[u8]) -> Self {
- Self::new(22, String::from_utf8_lossy(content))
- .with_mime(tree_magic::from_u8(content))
- .clone()
+ let mut response = Self::new(22, String::from_utf8_lossy(content));
+
+ response.with_mime(tree_magic::from_u8(content));
+
+ response
}
#[must_use]