🏗️ Elegant & Highly Performant Async Gemini Server Framework for the Modern Age
async framework gemini-protocol protocol gemini rust
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor(response): Optimise response building

Fuwn ec1bd9d7 6bc6224a

+16 -9
+16 -9
src/response.rs
··· 76 76 77 77 #[allow(clippy::needless_pass_by_value)] 78 78 pub fn success(content: impl ToString) -> Self { 79 - Self::new(20, content.to_string()) 79 + let mut response = Self::new(20, content.to_string()); 80 + 81 + response 80 82 .with_mime("text/gemini") 81 83 .with_languages(["en"]) 82 - .with_character_set("utf-8") 83 - .clone() 84 + .with_character_set("utf-8"); 85 + 86 + response 84 87 } 85 88 86 89 #[must_use] ··· 88 91 content: impl AsRef<[u8]>, 89 92 mime: impl Into<String> + AsRef<str>, 90 93 ) -> Self { 91 - Self::new(21, String::from_utf8_lossy(content.as_ref())) 92 - .with_mime(mime) 93 - .clone() 94 + let mut response = Self::new(21, String::from_utf8_lossy(content.as_ref())); 95 + 96 + response.with_mime(mime); 97 + 98 + response 94 99 } 95 100 96 101 #[cfg(feature = "auto-deduce-mime")] 97 102 #[must_use] 98 103 pub fn binary_success_auto(content: &[u8]) -> Self { 99 - Self::new(22, String::from_utf8_lossy(content)) 100 - .with_mime(tree_magic::from_u8(content)) 101 - .clone() 104 + let mut response = Self::new(22, String::from_utf8_lossy(content)); 105 + 106 + response.with_mime(tree_magic::from_u8(content)); 107 + 108 + response 102 109 } 103 110 104 111 #[must_use]