From 548f4b059d4fa158256be6b91604ea1961aaacb3 Mon Sep 17 00:00:00 2001 From: bunnie Date: Thu, 11 Aug 2022 03:11:38 +0800 Subject: [PATCH] chore: fix whitespace and warning --- services/shellchat/src/cmds/net_cmd.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/services/shellchat/src/cmds/net_cmd.rs b/services/shellchat/src/cmds/net_cmd.rs index 75e01240d..bc089534f 100644 --- a/services/shellchat/src/cmds/net_cmd.rs +++ b/services/shellchat/src/cmds/net_cmd.rs @@ -294,7 +294,7 @@ impl<'a> ShellCmdApi<'a> for NetCmd { } #[cfg(feature="ditherpunk")] "image" => { - if let Some(mut url) = tokens.next() { + if let Some(url) = tokens.next() { match url.split_once('/') { Some((host, path)) => { match TcpStream::connect((host, 80)) { @@ -312,7 +312,7 @@ impl<'a> ShellCmdApi<'a> for NetCmd { write!(stream, "Connection: close\r\n").expect("stream error"); write!(stream, "\r\n").expect("stream error"); log::info!("fetching response...."); - let mut reader = std::io::BufReader::new(&mut stream); + let mut reader = std::io::BufReader::new(&mut stream); let mut buf = Vec::::new(); let mut byte = [0u8; 1]; let mut content_length = 0; @@ -333,7 +333,7 @@ impl<'a> ShellCmdApi<'a> for NetCmd { log::info!("found end of header after {} lines.", line_count); break; }, - 1024.. => { + 1024.. => { let line = std::string::String::from_utf8_lossy(&buf); log::warn!("header contained line > 4k {:?}", line); break; @@ -354,23 +354,23 @@ impl<'a> ShellCmdApi<'a> for NetCmd { _ => {} } }; - buf.clear(); + buf.clear(); } - + if content_length > 0 { log::info!("heap size: {}", heap_usage()); let mut png = DecodePng::new(reader).expect("png decode failed"); const BORDER: u32 = 3; let modal_size = gam::Point::new( - (gam::IMG_MODAL_WIDTH - 2 * BORDER) as i16, + (gam::IMG_MODAL_WIDTH - 2 * BORDER) as i16, (gam::IMG_MODAL_HEIGHT - 2 * BORDER) as i16 ); let bm = gam::Bitmap::from_png(&mut png, Some(modal_size)); - + log::info!("heap size: {}", heap_usage()); let modals = modals::Modals::new(&env.xns).unwrap(); modals.show_image(bm).expect("show image modal failed"); - + } else { write!(ret, "content-length was 0, no image read").unwrap(); }