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:
parent
9fb772bfa8
commit
aa09666f4c
5 changed files with 73 additions and 67 deletions
26
src/util.rs
Normal file
26
src/util.rs
Normal 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()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue