toasty_core/error/
adhoc.rs1use super::Error;
2
3#[derive(Debug)]
5pub(super) struct Adhoc {
6 pub(super) message: Box<str>,
7}
8
9impl Adhoc {
10 pub(super) fn from_args<'a>(message: core::fmt::Arguments<'a>) -> Adhoc {
11 use std::string::ToString;
12
13 let message = message.to_string().into_boxed_str();
14 Adhoc { message }
15 }
16}
17
18impl std::error::Error for Adhoc {}
19
20impl core::fmt::Display for Adhoc {
21 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
22 core::fmt::Display::fmt(&self.message, f)
23 }
24}
25
26impl Error {
27 pub fn from_args<'a>(message: core::fmt::Arguments<'a>) -> Error {
37 Error::from(super::ErrorKind::Adhoc(Adhoc::from_args(message)))
38 }
39
40 pub fn is_adhoc(&self) -> bool {
42 matches!(self.kind(), super::ErrorKind::Adhoc(_))
43 }
44}