use crate::headers::Headers;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Response {
status: u16,
reason: String,
headers: Headers,
body: Vec<u8>,
}
impl Response {
#[must_use]
pub fn new(status: u16, reason: impl Into<String>, headers: Headers, body: Vec<u8>) -> Self {
Self {
status,
reason: reason.into(),
headers,
body,
}
}
#[must_use]
pub fn status(&self) -> u16 {
self.status
}
#[must_use]
pub fn reason(&self) -> &str {
&self.reason
}
#[must_use]
pub fn headers(&self) -> &Headers {
&self.headers
}
#[must_use]
pub fn body(&self) -> &[u8] {
&self.body
}
#[must_use]
pub fn body_text(&self) -> String {
String::from_utf8_lossy(&self.body).into_owned()
}
}