1#![deny(missing_debug_implementations, missing_docs)]
2
3use http::StatusCode;
8use std::collections::HashMap;
9
10pub trait ProblemDetails: ProblemDetailsReadOnly + ProblemDetailsMut + serde::Serialize {}
12
13impl ProblemDetails for Error {}
16
17pub trait ProblemDetailsReadOnly {
19 fn kind(&self) -> &str;
25
26 fn title(&self) -> &str;
30
31 fn status_code(&self) -> StatusCode;
34
35 fn detail(&self) -> Option<&str>;
37
38 fn extras(&self) -> &HashMap<String, String>;
40}
41
42impl ProblemDetailsReadOnly for Error {
43 fn status_code(&self) -> StatusCode {
44 self.status_code()
45 }
46
47 fn kind(&self) -> &str {
48 self.kind()
49 }
50
51 fn title(&self) -> &str {
52 self.title()
53 }
54
55 fn detail(&self) -> Option<&str> {
56 self.detail()
57 }
58
59 fn extras(&self) -> &HashMap<String, String> {
60 self.extras()
61 }
62}
63
64pub trait ProblemDetailsMut {
67 fn set_kind(&mut self, kind: &str, title: &str) -> &mut Self;
69
70 fn set_status_code(&mut self, value: StatusCode) -> &mut Self;
72
73 fn set_detail(&mut self, detail: &str) -> &mut Self;
75}
76
77impl ProblemDetailsMut for Error {
78 fn set_kind(&mut self, kind: &str, title: &str) -> &mut Self {
79 self.set_kind(kind, title)
80 }
81
82 fn set_status_code(&mut self, value: StatusCode) -> &mut Self {
83 self.set_status_code(value)
84 }
85
86 fn set_detail(&mut self, detail: &str) -> &mut Self {
87 self.set_detail(detail)
88 }
89}
90
91pub use self::error::{Builder, Error};
92mod error;
93
94pub mod extension;