From e75a6723df92972c137f001656bae5964f104376 Mon Sep 17 00:00:00 2001 From: Integral Date: Sat, 23 Sep 2023 12:07:19 +0800 Subject: [PATCH] adaptor/src/kitty.rs: optimize code readability --- adaptor/src/kitty.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/adaptor/src/kitty.rs b/adaptor/src/kitty.rs index fbd2980f..497a9ac0 100644 --- a/adaptor/src/kitty.rs +++ b/adaptor/src/kitty.rs @@ -1,4 +1,7 @@ -use std::{io::{stdout, Write}, path::Path}; +use std::{ + io::{stdout, Write}, + path::Path, +}; use anyhow::Result; use base64::{engine::general_purpose, Engine}; @@ -29,7 +32,7 @@ impl Kitty { } async fn encode(img: DynamicImage) -> Result> { - fn output(raw: &[u8], format: u8, size: (u32, u32)) -> Result> { + fn output(raw: &[u8], format: u8, (width, height): (u32, u32)) -> Result> { let b64 = general_purpose::STANDARD.encode(raw).chars().collect::>(); let mut it = b64.chunks(4096).peekable(); @@ -40,8 +43,8 @@ impl Kitty { "{}_Ga=T,f={},s={},v={},m={};{}{}\\{}", START, format, - size.0, - size.1, + width, + height, it.peek().is_some() as u8, first.iter().collect::(), ESCAPE,