style: run cargo fmt

This commit is contained in:
RafayAhmad7548 2026-09-03 13:06:30 +05:00
parent 6185a3123a
commit 809151b28c
Signed by: RafayAhmad
SSH key fingerprint: SHA256:WURX8viobA1uawb4dWM3LqYrY+XPcZcXhAXAlrYdhtE
3 changed files with 28 additions and 17 deletions

View file

@ -2,10 +2,13 @@ use std::error::Error;
use colored::Colorize;
use terminal_size;
use terminal_size::{Width, terminal_size as get_terminal_size};
use textwrap::{Options, fill};
use terminal_size::{terminal_size as get_terminal_size, Width};
use crate::models::{config::Config, search::{SearchQueryParams, SearchResult}};
use crate::models::{
config::Config,
search::{SearchQueryParams, SearchResult},
};
pub struct Search {
query: String,
@ -16,12 +19,12 @@ pub struct Search {
impl Search {
const BASE_URL: &str = "https://api.modrinth.com/v2";
pub fn new(
query: String,
offset: Option<u32>,
limit: Option<u32>,
) -> Self {
Search { query, offset, limit }
pub fn new(query: String, offset: Option<u32>, limit: Option<u32>) -> Self {
Search {
query,
offset,
limit,
}
}
pub async fn run(&self) -> Result<(), Box<dyn Error>> {
@ -66,12 +69,18 @@ impl Search {
fn print_results(&self, res: &SearchResult) {
println!(
"{}\n",
format!("Found {} result{}", res.total_hits, if res.total_hits == 1 { "" } else { "s" })
.green()
.bold()
format!(
"Found {} result{}",
res.total_hits,
if res.total_hits == 1 { "" } else { "s" }
)
.green()
.bold()
);
let width = get_terminal_size().map(|(Width(w), _)| w as usize).unwrap_or(80);
let width = get_terminal_size()
.map(|(Width(w), _)| w as usize)
.unwrap_or(80);
for (i, hit) in res.hits.iter().enumerate() {
let wrapped = fill(

View file

@ -2,10 +2,10 @@ use serde::{Deserialize, Serialize};
#[derive(Serialize)]
pub struct SearchQueryParams {
pub query: String,
pub facets: String,
pub offset: Option<u32>,
pub limit: Option<u32>,
pub query: String,
pub facets: String,
pub offset: Option<u32>,
pub limit: Option<u32>,
}
#[derive(Deserialize)]

View file

@ -1,4 +1,6 @@
use indicatif::{ProgressBar, ProgressStyle};
use sha1::{Digest, Sha1};
use sha2::Sha512;
use std::{error::Error, future::Future};
pub async fn with_spinner<F, Fut, T>(