chore: fix whitespace and warning

This commit is contained in:
bunnie 2022-08-11 03:11:38 +08:00
parent cfa65a3a72
commit 548f4b059d

View file

@ -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::<u8>::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();
}