diff --git a/lychee-bin/src/commands/check.rs b/lychee-bin/src/commands/check.rs index bbc550b4cf..58efa43ba1 100644 --- a/lychee-bin/src/commands/check.rs +++ b/lychee-bin/src/commands/check.rs @@ -16,7 +16,7 @@ use lychee_lib::{ResponseBody, Status}; use crate::archive::{Archive, Suggestion}; use crate::formatters::get_response_formatter; -use crate::formatters::response::ResponseBodyFormatter; +use crate::formatters::response::ResponseFormatter; use crate::verbosity::Verbosity; use crate::{cache::Cache, stats::ResponseStats, ExitCode}; @@ -181,7 +181,7 @@ async fn progress_bar_task( mut recv_resp: mpsc::Receiver, verbose: Verbosity, pb: Option, - formatter: Box, + formatter: Box, mut stats: ResponseStats, ) -> Result<(Option, ResponseStats)> { while let Some(response) = recv_resp.recv().await { @@ -298,7 +298,7 @@ fn show_progress( output: &mut dyn Write, progress_bar: &Option, response: &Response, - formatter: &dyn ResponseBodyFormatter, + formatter: &dyn ResponseFormatter, verbose: &Verbosity, ) -> Result<()> { let out = formatter.format_response(response.body()); diff --git a/lychee-bin/src/formatters/mod.rs b/lychee-bin/src/formatters/mod.rs index 7ea7ff1e84..a2e0fde910 100644 --- a/lychee-bin/src/formatters/mod.rs +++ b/lychee-bin/src/formatters/mod.rs @@ -4,7 +4,7 @@ pub(crate) mod log; pub(crate) mod response; pub(crate) mod stats; -use self::{response::ResponseBodyFormatter, stats::StatsFormatter}; +use self::{response::ResponseFormatter, stats::StatsFormatter}; use crate::options::{OutputMode, StatsFormat}; use supports_color::Stream; @@ -29,7 +29,7 @@ pub(crate) fn get_stats_formatter( } /// Create a response formatter based on the given format option -pub(crate) fn get_response_formatter(mode: &OutputMode) -> Box { +pub(crate) fn get_response_formatter(mode: &OutputMode) -> Box { if !supports_color() { return Box::new(response::PlainFormatter); } diff --git a/lychee-bin/src/formatters/response/color.rs b/lychee-bin/src/formatters/response/color.rs index c08ab47e99..c5016698be 100644 --- a/lychee-bin/src/formatters/response/color.rs +++ b/lychee-bin/src/formatters/response/color.rs @@ -2,7 +2,7 @@ use lychee_lib::{CacheStatus, ResponseBody, Status}; use crate::formatters::color::{DIM, GREEN, NORMAL, PINK, YELLOW}; -use super::{ResponseBodyFormatter, MAX_RESPONSE_OUTPUT_WIDTH}; +use super::{ResponseFormatter, MAX_RESPONSE_OUTPUT_WIDTH}; /// A colorized formatter for the response body /// @@ -10,7 +10,7 @@ use super::{ResponseBodyFormatter, MAX_RESPONSE_OUTPUT_WIDTH}; /// has not explicitly requested raw, uncolored output. pub(crate) struct ColorFormatter; -impl ResponseBodyFormatter for ColorFormatter { +impl ResponseFormatter for ColorFormatter { fn format_response(&self, body: &ResponseBody) -> String { // Determine the color based on the status. let status_color = match body.status { diff --git a/lychee-bin/src/formatters/response/emoji.rs b/lychee-bin/src/formatters/response/emoji.rs index ea70fc0ff9..75062f2d1d 100644 --- a/lychee-bin/src/formatters/response/emoji.rs +++ b/lychee-bin/src/formatters/response/emoji.rs @@ -1,6 +1,6 @@ use lychee_lib::{CacheStatus, ResponseBody, Status}; -use super::ResponseBodyFormatter; +use super::ResponseFormatter; /// An emoji formatter for the response body /// @@ -8,7 +8,7 @@ use super::ResponseBodyFormatter; /// visual output. pub(crate) struct EmojiFormatter; -impl ResponseBodyFormatter for EmojiFormatter { +impl ResponseFormatter for EmojiFormatter { fn format_response(&self, body: &ResponseBody) -> String { let emoji = match body.status { Status::Ok(_) | Status::Cached(CacheStatus::Ok(_)) => "✅", diff --git a/lychee-bin/src/formatters/response/mod.rs b/lychee-bin/src/formatters/response/mod.rs index 5d0e668b5f..ac615b5be0 100644 --- a/lychee-bin/src/formatters/response/mod.rs +++ b/lychee-bin/src/formatters/response/mod.rs @@ -22,6 +22,6 @@ pub(crate) const MAX_RESPONSE_OUTPUT_WIDTH: usize = 10; /// This trait is used to convert response body into a human-readable string. /// It can be implemented for different formatting styles such as /// colorized output or plaintext. -pub(crate) trait ResponseBodyFormatter: Send + Sync { +pub(crate) trait ResponseFormatter: Send + Sync { fn format_response(&self, body: &ResponseBody) -> String; } diff --git a/lychee-bin/src/formatters/response/plain.rs b/lychee-bin/src/formatters/response/plain.rs index bd2d0e4c5e..be4c8fae0a 100644 --- a/lychee-bin/src/formatters/response/plain.rs +++ b/lychee-bin/src/formatters/response/plain.rs @@ -1,6 +1,6 @@ use lychee_lib::ResponseBody; -use super::ResponseBodyFormatter; +use super::ResponseFormatter; /// A basic formatter that just returns the response body as a string /// without any color codes or other formatting. @@ -12,7 +12,7 @@ use super::ResponseBodyFormatter; /// or when the terminal does not support color. pub(crate) struct PlainFormatter; -impl ResponseBodyFormatter for PlainFormatter { +impl ResponseFormatter for PlainFormatter { fn format_response(&self, body: &ResponseBody) -> String { body.to_string() }