scsys_core/error/
std_error.rs1use crate::error::ErrorKind;
6use alloc::string::{String, ToString};
7
8pub struct StdError<K: ErrorKind = String> {
11 pub(crate) kind: K,
12 pub(crate) message: String,
13}
14
15impl<K> StdError<K>
16where
17 K: ErrorKind,
18{
19 pub fn kind(&self) -> &K {
21 &self.kind
22 }
23 pub fn kind_mut(&mut self) -> &mut K {
25 &mut self.kind
26 }
27 pub fn message(&self) -> &str {
29 &self.message
30 }
31 pub fn set_kind(&mut self, value: K) -> &mut Self {
33 self.kind = value;
34 self
35 }
36 pub fn set_message<V: ToString>(&mut self, value: V) -> &mut Self {
38 self.message = value.to_string();
39 self
40 }
41 pub fn with_kind(self, kind: K) -> Self {
43 Self { kind, ..self }
44 }
45 pub fn with_message(self, message: String) -> Self {
47 Self { message, ..self }
48 }
49}
50
51unsafe impl<K: ErrorKind> Send for StdError<K> {}
52
53unsafe impl<K: ErrorKind> Sync for StdError<K> {}