/rust/registry/src/index.crates.io-1949cf8c6b5b557f/sval-2.16.0/src/result.rs
Line | Count | Source |
1 | | use crate::std::fmt; |
2 | | |
3 | | /** |
4 | | An error encountered while streaming a value. |
5 | | |
6 | | Errors don't capture details of failures, that responsibility is left |
7 | | to the stream to surface. |
8 | | */ |
9 | | #[derive(Debug)] |
10 | | pub struct Error(()); |
11 | | |
12 | | impl Error { |
13 | | /** |
14 | | Create a new error. |
15 | | |
16 | | More detailed diagnostic information will need to be stored elsewhere. |
17 | | */ |
18 | | #[inline(always)] |
19 | 0 | pub fn new() -> Self { |
20 | 0 | Error(()) |
21 | 0 | } |
22 | | } |
23 | | |
24 | | impl fmt::Display for Error { |
25 | 0 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
26 | 0 | write!(f, "failed to stream data") |
27 | 0 | } |
28 | | } |
29 | | |
30 | | #[cfg(feature = "std")] |
31 | | mod std_support { |
32 | | use super::*; |
33 | | |
34 | | use crate::std::error; |
35 | | |
36 | | impl error::Error for Error {} |
37 | | } |
38 | | |
39 | | /** |
40 | | A streaming result with a generic failure. |
41 | | |
42 | | More detailed diagnostic information will need to be stored elsewhere. |
43 | | */ |
44 | | #[inline(always)] |
45 | 0 | pub fn error<T>() -> crate::Result<T> { |
46 | 0 | Err(Error::new()) |
47 | 0 | } Unexecuted instantiation: sval::result::error::<()> Unexecuted instantiation: sval::result::error::<()> Unexecuted instantiation: sval::result::error::<()> |