mirror of
https://github.com/YGGverse/aquatic-crawler.git
synced 2026-04-01 09:35:37 +00:00
implement item description format helper
This commit is contained in:
parent
51ffa4d93d
commit
82d2a89aa2
2 changed files with 28 additions and 12 deletions
17
src/rss.rs
17
src/rss.rs
|
|
@ -92,6 +92,23 @@ impl Rss {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn item_description(size: Option<u64>, list: Option<&Vec<(String, u64)>>) -> Option<String> {
|
||||
if size.is_none() && list.is_none() {
|
||||
return None;
|
||||
}
|
||||
let mut b = Vec::with_capacity(list.map(|l| l.len()).unwrap_or_default() + 1);
|
||||
if let Some(s) = size {
|
||||
use crate::format::Format;
|
||||
b.push(s.bytes())
|
||||
}
|
||||
if let Some(l) = list {
|
||||
for (path, size) in l {
|
||||
b.push(format!("* {path}: {size}"))
|
||||
}
|
||||
}
|
||||
Some(b.join("<br>\n"))
|
||||
}
|
||||
|
||||
fn escape(subject: &str) -> String {
|
||||
subject
|
||||
.replace('&', "&")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue