From bc0de9955c375cf27d52c9934403964205afc182 Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 29 Oct 2026 22:16:15 +0100 Subject: formatting --- src/bin/client/repl.rs | 27 +++++++++------------------ src/bin/client/tls.rs | 17 ++++++++--------- 2 files changed, 17 insertions(+), 27 deletions(-) (limited to 'src/bin/client') diff --git a/src/bin/client/repl.rs b/src/bin/client/repl.rs index 7fa462a..9af4ea9 100644 --- a/src/bin/client/repl.rs +++ b/src/bin/client/repl.rs @@ -1,14 +1,14 @@ use rusqlite::Connection; -use std::io::{stdout, Write}; +use std::io::{Write, stdout}; use std::sync::{Arc, Mutex}; use std::time::Instant; use crossterm::{ cursor::{MoveToColumn, MoveUp, Show}, - event::{read, Event, KeyCode, KeyEventKind, KeyModifiers}, + event::{Event, KeyCode, KeyEventKind, KeyModifiers, read}, execute, style::Stylize, - terminal::{disable_raw_mode, enable_raw_mode, Clear, ClearType}, + terminal::{Clear, ClearType, disable_raw_mode, enable_raw_mode}, }; use sha2::{Digest, Sha256}; @@ -20,7 +20,7 @@ use zagan_bet::client::ui::{ visual_line_count, }; use zagan_bet::protocol::io_failure_message; -use zagan_bet::roulette::{color as roulette_color, WHEEL}; +use zagan_bet::roulette::{WHEEL, color as roulette_color}; use crate::connection::TlsStream; @@ -71,8 +71,7 @@ impl ClientState { self.core.set_connected(true); self.core.set_logged_in(authed_user); let fingerprint = database::get_fingerprint(&self.conn, addr); - self.core - .set_host_info(Some(addr.to_string()), fingerprint); + self.core.set_host_info(Some(addr.to_string()), fingerprint); database::save_host(&self.conn, addr); } Err(e) => { @@ -178,12 +177,9 @@ impl ClientState { Effect::Print(lines) => { self.commit_prompt_line(); for line in lines { - let rendered = if line.starts_with("ERROR") - || line.contains("failed") - { + let rendered = if line.starts_with("ERROR") || line.contains("failed") { line.as_str().red().to_string() - } else if line.starts_with("Logged in") - || line.starts_with("Successfully") + } else if line.starts_with("Logged in") || line.starts_with("Successfully") { line.as_str().green().to_string() } else if line.starts_with("Available commands:") @@ -249,10 +245,7 @@ impl ClientState { Effect::ForgetHost(target) => { self.commit_prompt_line(); match database::forget_host(&self.conn, &target) { - Ok(_) => println!( - "Cleared trust and stored credentials for {}.", - target - ), + Ok(_) => println!("Cleared trust and stored credentials for {}.", target), Err(error) => println!("Failed to forget host: {}", error), } } @@ -297,9 +290,7 @@ impl ClientState { let roulette = lines .first() .is_some_and(|first| first.contains("ROULETTE")); - let crash = lines - .first() - .is_some_and(|first| first.contains("CRASH")); + let crash = lines.first().is_some_and(|first| first.contains("CRASH")); let rendered: Vec = lines .iter() .map(|line| { diff --git a/src/bin/client/tls.rs b/src/bin/client/tls.rs index b46f52b..e14ed98 100644 --- a/src/bin/client/tls.rs +++ b/src/bin/client/tls.rs @@ -17,10 +17,10 @@ use std::net::TcpStream; use std::sync::Arc; use parking_lot::Mutex; -use rustls::client::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier}; use rustls::DigitallySignedStruct; +use rustls::client::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier}; use zagan_bet::protocol::LineBuffer; -use zagan_bet::tofu::{decide, spki_fingerprint, TrustDecision}; +use zagan_bet::tofu::{TrustDecision, decide, spki_fingerprint}; pub struct TlsConnector { config: Arc, @@ -53,7 +53,10 @@ impl TlsConnector { }) } - pub fn connect(&self, stream: TcpStream) -> Result> { + pub fn connect( + &self, + stream: TcpStream, + ) -> Result> { let mut conn = rustls::ClientConnection::new(Arc::clone(&self.config), self.server_name.clone())?; let mut sock = stream; @@ -200,10 +203,7 @@ impl TlsStream { } /// Apply a read timeout to the underlying TCP socket. - pub fn set_read_timeout( - &self, - duration: Option, - ) -> std::io::Result<()> { + pub fn set_read_timeout(&self, duration: Option) -> std::io::Result<()> { let mut s = self.session.lock(); s.read_timeout = duration; s.sock.set_read_timeout(duration) @@ -235,8 +235,7 @@ impl TlsStream { Err(error) if matches!( error.kind(), - std::io::ErrorKind::WouldBlock - | std::io::ErrorKind::TimedOut + std::io::ErrorKind::WouldBlock | std::io::ErrorKind::TimedOut ) => { return Ok(()); -- cgit v1.2.3