use crate::protocol::StatusCode;
#[derive(Debug, Clone, PartialEq)]
pub struct StatusReply {
pub status_code: StatusCode,
pub error_message: Option<String>,
pub language_tag: Option<String>,
}
impl StatusReply {
pub fn new(status_code: StatusCode) -> Self {
Self {
status_code,
error_message: None,
language_tag: None,
}
}
pub fn with_message(mut self, message: impl Into<String>) -> Self {
self.error_message = Some(message.into());
self
}
pub fn with_language_tag(mut self, tag: impl Into<String>) -> Self {
self.language_tag = Some(tag.into());
self
}
}
impl From<StatusCode> for StatusReply {
fn from(status_code: StatusCode) -> Self {
Self::new(status_code)
}
}
impl StatusCode {
pub fn with_message(self, message: impl Into<String>) -> StatusReply {
StatusReply::new(self).with_message(message)
}
}