summaryrefslogtreecommitdiff
path: root/src/channel/header.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/channel/header.rs')
-rw-r--r--src/channel/header.rs34
1 files changed, 0 insertions, 34 deletions
diff --git a/src/channel/header.rs b/src/channel/header.rs
deleted file mode 100644
index eda8214..0000000
--- a/src/channel/header.rs
+++ /dev/null
@@ -1,34 +0,0 @@
-use axum::http::{HeaderName, HeaderValue};
-
-pub struct LastEventId(pub String);
-
-static LAST_EVENT_ID: HeaderName = HeaderName::from_static("last-event-id");
-
-impl headers::Header for LastEventId {
- fn name() -> &'static HeaderName {
- &LAST_EVENT_ID
- }
-
- fn decode<'i, I>(values: &mut I) -> Result<Self, headers::Error>
- where
- I: Iterator<Item = &'i HeaderValue>,
- {
- let value = values.next().ok_or_else(headers::Error::invalid)?;
- if let Ok(value) = value.to_str() {
- Ok(Self(value.into()))
- } else {
- Err(headers::Error::invalid())
- }
- }
-
- fn encode<E>(&self, values: &mut E)
- where
- E: Extend<HeaderValue>,
- {
- let Self(value) = self;
- // Must panic or suppress; the trait provides no other options.
- let value = HeaderValue::from_str(value).expect("LastEventId is a valid header value");
-
- values.extend(std::iter::once(value));
- }
-}