From 9756371aa37bf66a801aa608b29a05deec7565a3 Mon Sep 17 00:00:00 2001 From: Daniel Grimm Date: Fri, 20 Nov 2020 10:32:04 +0100 Subject: [PATCH] rustfmt Signed-off-by: Daniel Grimm --- examples/http_config.rs | 15 ++++++--------- src/dispatcher.rs | 8 ++++++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/examples/http_config.rs b/examples/http_config.rs index f2aaeef7..1536d7a0 100644 --- a/examples/http_config.rs +++ b/examples/http_config.rs @@ -12,28 +12,27 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::str; use proxy_wasm::traits::*; use proxy_wasm::types::*; +use std::str; #[no_mangle] pub fn _start() { proxy_wasm::set_log_level(LogLevel::Trace); proxy_wasm::set_root_context(|_| -> Box { - Box::new(HttpConfigHeaderRootContext{ + Box::new(HttpConfigHeaderRootContext { header_content: "".to_string(), }) }); } -struct HttpConfigHeader{ - header_content: String +struct HttpConfigHeader { + header_content: String, } impl Context for HttpConfigHeader {} impl HttpContext for HttpConfigHeader { - fn on_http_response_headers(&mut self, _num_headers: usize) -> Action { self.add_http_response_header("custom-header", self.header_content.as_str()); @@ -42,13 +41,12 @@ impl HttpContext for HttpConfigHeader { } struct HttpConfigHeaderRootContext { - header_content: String + header_content: String, } impl Context for HttpConfigHeaderRootContext {} impl RootContext for HttpConfigHeaderRootContext { - fn on_configure(&mut self, _plugin_configuration_size: usize) -> bool { if let Some(config_bytes) = self.get_configuration() { self.header_content = str::from_utf8(config_bytes.as_ref()).unwrap().to_owned() @@ -57,7 +55,7 @@ impl RootContext for HttpConfigHeaderRootContext { } fn create_http_context(&self, _context_id: u32) -> Option> { - Some(Box::new(HttpConfigHeader{ + Some(Box::new(HttpConfigHeader { header_content: self.header_content.clone(), })) } @@ -65,5 +63,4 @@ impl RootContext for HttpConfigHeaderRootContext { fn get_type(&self) -> Option { Some(ContextType::HttpContext) } - } diff --git a/src/dispatcher.rs b/src/dispatcher.rs index 07b22b55..4c84733c 100644 --- a/src/dispatcher.rs +++ b/src/dispatcher.rs @@ -157,8 +157,12 @@ impl Dispatcher { self.create_stream_context(context_id, root_context_id); } else if let Some(root_context) = self.roots.borrow().get(&root_context_id) { match root_context.get_type() { - Some(ContextType::HttpContext) => self.create_http_context(context_id, root_context_id), - Some(ContextType::StreamContext) => self.create_stream_context(context_id, root_context_id), + Some(ContextType::HttpContext) => { + self.create_http_context(context_id, root_context_id) + } + Some(ContextType::StreamContext) => { + self.create_stream_context(context_id, root_context_id) + } None => panic!("missing ContextType on root_context"), } } else {