From ee908067a7060113993459ecdd96c7abb3e2d0c2 Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Sat, 26 Apr 2025 21:34:00 +0200 Subject: [PATCH] Some more comments --- crates/lune-std-net/src/shared/response.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/lune-std-net/src/shared/response.rs b/crates/lune-std-net/src/shared/response.rs index df3a183..3f9b8e8 100644 --- a/crates/lune-std-net/src/shared/response.rs +++ b/crates/lune-std-net/src/shared/response.rs @@ -17,6 +17,9 @@ pub struct Response { } impl Response { + /** + Creates a new response from a raw incoming response. + */ pub async fn from_incoming( incoming: HyperResponse, decompressed: bool, @@ -44,22 +47,37 @@ impl Response { }) } + /** + Returns whether the request was successful or not. + */ pub fn status_ok(&self) -> bool { self.inner.status().is_success() } + /** + Returns the status code of the response. + */ pub fn status_code(&self) -> u16 { self.inner.status().as_u16() } + /** + Returns the status message of the response. + */ pub fn status_message(&self) -> &str { self.inner.status().canonical_reason().unwrap_or_default() } + /** + Returns the headers of the response. + */ pub fn headers(&self) -> &HeaderMap { self.inner.headers() } + /** + Returns the body of the response. + */ pub fn body(&self) -> &[u8] { self.inner.body() }