1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use crate::{actors::extract::base_extractor, DEFAULT_IGNORE_CHARS};
use std::str::FromStr;
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct Extractor<'a> {
pub breakpoint: char,
pub data: String,
pub exclude: &'a [char],
}
impl<'a> Extractor<'a> {
pub fn new(breakpoint: char, data: String, exclude: Option<&'a [char]>) -> Self {
let exclude = exclude.unwrap_or(DEFAULT_IGNORE_CHARS);
Self {
breakpoint,
data,
exclude,
}
}
pub fn extract<T: FromStr + ToString>(&self) -> Vec<T>
where
<T as FromStr>::Err: std::fmt::Debug,
{
base_extractor::<String, T>(self.breakpoint, &self.data, Some(self.exclude))
}
}