pub struct ApiErrorContext {
pub(crate) title: String,
pub(crate) detail: Option<String>,
}
impl From<&str> for ApiErrorContext {
fn from(title: &str) -> Self {
Self {
title: title.to_string(),
detail: None,
}
}
}
impl From<String> for ApiErrorContext {
fn from(title: String) -> Self {
Self {
title,
detail: None,
}
}
}
impl From<(&str, &str)> for ApiErrorContext {
fn from((title, detail): (&str, &str)) -> Self {
Self {
title: title.to_string(),
detail: Some(detail.to_string()),
}
}
}
impl From<(String, String)> for ApiErrorContext {
fn from((title, detail): (String, String)) -> Self {
Self {
title,
detail: Some(detail),
}
}
}
impl From<(&str, String)> for ApiErrorContext {
fn from((title, detail): (&str, String)) -> Self {
Self {
title: title.to_string(),
detail: Some(detail),
}
}
}
impl From<(String, &str)> for ApiErrorContext {
fn from((title, detail): (String, &str)) -> Self {
Self {
title,
detail: Some(detail.to_string()),
}
}
}