use crate::response::{ErrorResult, ServiceResult};
pub struct Okay;
impl Okay {
pub fn result<T: serde::Serialize>(data: T) -> ServiceResult<T> { ServiceResult::ok("OK", data) }
pub fn empty() -> ServiceResult<()> { ServiceResult::new("success", "OK", None, 200) }
}
pub struct AuthenticationError;
impl AuthenticationError {
pub fn new(msg: impl Into<String>) -> ErrorResult { ErrorResult::new(msg, None, 401) }
}
pub struct AuthorizationError;
impl AuthorizationError {
pub fn new(msg: impl Into<String>) -> ErrorResult { ErrorResult::new(msg, None, 403) }
}
pub struct BadConfiguration;
impl BadConfiguration {
pub fn new(msg: impl Into<String>) -> ErrorResult { ErrorResult::new(msg, None, 500) }
}
pub struct GenericError;
impl GenericError {
pub fn new(msg: impl Into<String>, code: u16) -> ErrorResult { ErrorResult::new(msg, None, code) }
}