scsys_core/error/
std_error.rs1#![cfg(feature = "alloc")]
6use crate::error::ErrorKind;
7use alloc::string::{String, ToString};
8
9pub struct StdError<K: ErrorKind = String> {
12 pub(crate) kind: K,
13 pub(crate) message: String,
14}
15
16impl<K> StdError<K>
17where
18 K: ErrorKind,
19{
20 pub fn kind(&self) -> &K {
22 &self.kind
23 }
24 pub fn kind_mut(&mut self) -> &mut K {
26 &mut self.kind
27 }
28 pub fn message(&self) -> &str {
30 &self.message
31 }
32 pub fn set_kind(&mut self, value: K) -> &mut Self {
34 self.kind = value;
35 self
36 }
37 pub fn set_message<V: ToString>(&mut self, value: V) -> &mut Self {
39 self.message = value.to_string();
40 self
41 }
42 pub fn with_kind(self, kind: K) -> Self {
44 Self { kind, ..self }
45 }
46 pub fn with_message(self, message: String) -> Self {
48 Self { message, ..self }
49 }
50}
51
52unsafe impl<K: ErrorKind> Send for StdError<K> {}
53
54unsafe impl<K: ErrorKind> Sync for StdError<K> {}