use vector to keep the order from the arguments list

This commit is contained in:
yggverse 2025-08-05 18:27:42 +03:00
parent 52fc71a30a
commit c8e0215e1c
3 changed files with 7 additions and 8 deletions

View file

@ -1,5 +1,4 @@
use crate::format; use crate::format;
use std::collections::HashSet;
use url::Url; use url::Url;
/// Export crawl index to the RSS file /// Export crawl index to the RSS file
@ -7,7 +6,7 @@ pub struct Feed {
description: Option<String>, description: Option<String>,
link: Option<String>, link: Option<String>,
title: String, title: String,
trackers: Option<HashSet<Url>>, trackers: Option<Vec<Url>>,
} }
impl Feed { impl Feed {
@ -15,7 +14,7 @@ impl Feed {
title: String, title: String,
description: Option<String>, description: Option<String>,
link: Option<Url>, link: Option<Url>,
trackers: Option<HashSet<Url>>, trackers: Option<Vec<Url>>,
) -> Self { ) -> Self {
Self { Self {
description: description.map(escape), description: description.map(escape),

View file

@ -16,7 +16,7 @@ pub fn bytes(value: u64) -> String {
} }
} }
pub fn magnet(info_hash: &str, trackers: Option<&std::collections::HashSet<url::Url>>) -> String { pub fn magnet(info_hash: &str, trackers: Option<&Vec<url::Url>>) -> String {
let mut b = if info_hash.len() == 40 { let mut b = if info_hash.len() == 40 {
format!("magnet:?xt=urn:btih:{info_hash}") format!("magnet:?xt=urn:btih:{info_hash}")
} else { } else {

View file

@ -15,7 +15,6 @@ use rocket::{
serde::Serialize, serde::Serialize,
}; };
use rocket_dyn_templates::{Template, context}; use rocket_dyn_templates::{Template, context};
use std::collections::HashSet;
use storage::{Order, Sort, Storage, Torrent}; use storage::{Order, Sort, Storage, Torrent};
use url::Url; use url::Url;
@ -27,7 +26,8 @@ pub struct Meta {
pub format_time: String, pub format_time: String,
pub stats: Option<Url>, pub stats: Option<Url>,
pub title: String, pub title: String,
pub trackers: Option<HashSet<Url>>, /// * use vector to keep the order from the arguments list
pub trackers: Option<Vec<Url>>,
} }
#[get("/?<page>")] #[get("/?<page>")]
@ -99,7 +99,7 @@ fn rocket() -> _ {
config.title.clone(), config.title.clone(),
config.description.clone(), config.description.clone(),
config.link.clone(), config.link.clone(),
config.tracker.clone().map(|u| u.into_iter().collect()), config.tracker.clone(),
); );
let storage = Storage::init(config.storage, config.list_limit, config.capacity).unwrap(); // @TODO handle let storage = Storage::init(config.storage, config.list_limit, config.capacity).unwrap(); // @TODO handle
rocket::build() rocket::build()
@ -117,7 +117,7 @@ fn rocket() -> _ {
format_time: config.format_time, format_time: config.format_time,
stats: config.stats, stats: config.stats,
title: config.title, title: config.title,
trackers: config.tracker.map(|u| u.into_iter().collect()), trackers: config.tracker,
}) })
.mount("/", routes![index, rss]) .mount("/", routes![index, rss])
} }