somen/stream/rewind/buffered/
error.rs1use core::fmt;
2
3#[derive(Clone, Debug, PartialEq, Eq)]
7#[cfg_attr(feature = "nightly", doc(cfg(feature = "alloc")))]
8pub enum BufferedError<S> {
9 Stream(S),
10 Buffer,
11}
12
13impl<S: fmt::Display> fmt::Display for BufferedError<S> {
14 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15 match self {
16 Self::Stream(e) => write!(f, "{}", e),
17 Self::Buffer => write!(f, "a marker used by illegal order"),
18 }
19 }
20}
21
22#[cfg(feature = "std")]
23#[cfg_attr(feature = "nightly", doc(cfg(feature = "std")))]
24impl<S: std::error::Error + 'static> std::error::Error for BufferedError<S> {
25 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
26 match self {
27 Self::Stream(e) => Some(e),
28 Self::Buffer => None,
29 }
30 }
31}