Trait edm_core::response::ResponseCode
source · pub trait ResponseCode {
type ErrorCode: Serialize;
type BusinessCode: Serialize;
const OK: Self;
const BAD_REQUEST: Self;
const INTERNAL_SERVER_ERROR: Self;
// Required methods
fn status_code(&self) -> u16;
fn is_success(&self) -> bool;
// Provided methods
fn error_code(&self) -> Option<Self::ErrorCode> { ... }
fn business_code(&self) -> Option<Self::BusinessCode> { ... }
fn type_uri(&self) -> Option<SharedString> { ... }
fn title(&self) -> Option<SharedString> { ... }
fn message(&self) -> Option<SharedString> { ... }
}Expand description
Trait for response code. See Problem Details for HTTP APIs.
Required Associated Types§
sourcetype BusinessCode: Serialize
type BusinessCode: Serialize
A type for the business code.
Required Associated Constants§
sourceconst BAD_REQUEST: Self
const BAD_REQUEST: Self
400 Bad Request.
sourceconst INTERNAL_SERVER_ERROR: Self
const INTERNAL_SERVER_ERROR: Self
500 Internal Server Error.
Required Methods§
sourcefn status_code(&self) -> u16
fn status_code(&self) -> u16
Status code.
sourcefn is_success(&self) -> bool
fn is_success(&self) -> bool
Returns true if the response is successful.
Provided Methods§
sourcefn error_code(&self) -> Option<Self::ErrorCode>
fn error_code(&self) -> Option<Self::ErrorCode>
Error code.
sourcefn business_code(&self) -> Option<Self::BusinessCode>
fn business_code(&self) -> Option<Self::BusinessCode>
Business code.
sourcefn type_uri(&self) -> Option<SharedString>
fn type_uri(&self) -> Option<SharedString>
A URI reference that identifies the problem type.
For successful response, it should be None.
sourcefn title(&self) -> Option<SharedString>
fn title(&self) -> Option<SharedString>
A short, human-readable summary of the problem type.
For successful response, it should be None.
sourcefn message(&self) -> Option<SharedString>
fn message(&self) -> Option<SharedString>
A context-specific descriptive message. If the response is not successful, it should be a human-readable explanation specific to this occurrence of the problem.
Object Safety§
This trait is not object safe.