1
0
Fork 0
mirror of https://gitlab.com/news-flash/article_scraper.git synced 2025-07-08 08:30:00 +02:00

async config loading

This commit is contained in:
Jan Lukas Gernert 2022-10-05 06:53:05 +02:00
parent 9fb772bfa8
commit aa09666f4c
5 changed files with 73 additions and 67 deletions

26
src/util.rs Normal file
View file

@ -0,0 +1,26 @@
use tokio::fs::DirEntry;
pub struct Util;
impl Util {
pub fn check_extension(path: &DirEntry, extension: &str) -> bool {
if let Some(ext) = path.path().extension() {
ext.to_str() == Some(extension)
} else {
false
}
}
pub fn extract_value<'a>(identifier: &str, line: &'a str) -> &'a str {
let value = &line[identifier.len()..];
let value = value.trim();
match value.find('#') {
Some(pos) => &value[..pos],
None => value,
}
}
pub fn split_values(values: &str) -> Vec<&str> {
values.split('|').map(|s| s.trim()).collect()
}
}