From faa7c8ceced0b0b4b246ce12c5933e13817f4fce Mon Sep 17 00:00:00 2001 From: kouta Date: Mon, 25 Mar 2024 13:18:07 -0300 Subject: [PATCH] Apply cargo fmt --- src/filters/sse.rs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/filters/sse.rs b/src/filters/sse.rs index 262448a6..4fcb9965 100644 --- a/src/filters/sse.rs +++ b/src/filters/sse.rs @@ -315,7 +315,10 @@ where S: TryStream + Send + 'static, S::Error: StdError + Send + Sync + 'static, { - SseReply { event_stream, charset: None } + SseReply { + event_stream, + charset: None, + } } /// Server-sent events reply (with explicit charset) @@ -400,13 +403,16 @@ where S: TryStream + Send + 'static, S::Error: StdError + Send + Sync + 'static, { - SseReply { event_stream, charset: Some(charset) } + SseReply { + event_stream, + charset: Some(charset), + } } #[allow(missing_debug_implementations)] struct SseReply { event_stream: S, - charset: Option + charset: Option, } impl Reply for SseReply @@ -428,11 +434,16 @@ where let mut res = Response::new(Body::wrap_stream(body_stream)); // Set appropriate content type - res.headers_mut() - .insert(CONTENT_TYPE, match self.charset { + res.headers_mut().insert( + CONTENT_TYPE, + match self.charset { None => HeaderValue::from_static("text/event-stream"), - Some(charset) => HeaderValue::from_str(format!("text/event-stream; charset={}", charset).as_str()).expect("Invalid header value"), - }); + Some(charset) => HeaderValue::from_str( + format!("text/event-stream; charset={}", charset).as_str(), + ) + .expect("Invalid header value"), + }, + ); // Disable response body caching res.headers_mut() .insert(CACHE_CONTROL, HeaderValue::from_static("no-cache"));