fire_http_api/stream/
error.rs

1use std::borrow::Cow;
2use std::fmt;
3
4pub use serde_json::Error as JsonError;
5
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct UnrecoverableError(Cow<'static, str>);
8
9impl From<&'static str> for UnrecoverableError {
10	fn from(s: &'static str) -> Self {
11		Self(s.into())
12	}
13}
14
15impl From<String> for UnrecoverableError {
16	fn from(s: String) -> Self {
17		Self(s.into())
18	}
19}
20
21impl fmt::Display for UnrecoverableError {
22	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
23		fmt::Debug::fmt(self, f)
24	}
25}
26
27#[derive(Debug)]
28pub enum StreamError {
29	Closed,
30	Json(JsonError),
31}
32
33impl std::error::Error for StreamError {}
34
35impl fmt::Display for StreamError {
36	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
37		fmt::Debug::fmt(self, f)
38	}
39}