use crate::error::ErrorKind;
use alloc::string::{String, ToString};
pub struct StdError<K: ErrorKind = String> {
pub(crate) kind: K,
pub(crate) message: String,
}
impl<K> StdError<K>
where
K: ErrorKind,
{
pub fn kind(&self) -> &K {
&self.kind
}
pub fn kind_mut(&mut self) -> &mut K {
&mut self.kind
}
pub fn message(&self) -> &str {
&self.message
}
pub fn set_kind(&mut self, value: K) -> &mut Self {
self.kind = value;
self
}
pub fn set_message<V: ToString>(&mut self, value: V) -> &mut Self {
self.message = value.to_string();
self
}
pub fn with_kind(self, kind: K) -> Self {
Self { kind, ..self }
}
pub fn with_message(self, message: String) -> Self {
Self { message, ..self }
}
}
unsafe impl<K: ErrorKind> Send for StdError<K> {}
unsafe impl<K: ErrorKind> Sync for StdError<K> {}