pub struct ParsedPattern { /* private fields */ }
Expand description
Parses path to directory and name, then parses name to vector of patterns with ‘*’ delimeter
Implementations§
Source§impl ParsedPattern
impl ParsedPattern
Sourcepub fn new(path: &Path) -> Self
pub fn new(path: &Path) -> Self
Parses path to directory and name, then parses name to vector of patterns with ‘*’ delimeter, returning ParsedPattern
§Arguments
path
- A &Path object, representing path with tempate name of file (i.e. name with ‘’ symbols) If path is empty, pattern will be vec![“”]; If path is ‘’, pattern will be vec![]
§Examples
use mmv_lib::input_parser::ParsedPattern;
use std::path::Path;
let path = Path::new("src/te*.txt");
let parsed_pattern = ParsedPattern::new(&path);
Sourcepub fn match_to_pattern(&self, file_name: &String) -> Result<Vec<String>, ()>
pub fn match_to_pattern(&self, file_name: &String) -> Result<Vec<String>, ()>
Matching file name with pattern, and if it fits, return vector of fragments, which was read as template
§Arguments
file_name
- A &String, representing name of file.
§Error
If file name doesn’t fit to the pattern, return ()
§Examples
use mmv_lib::input_parser::ParsedPattern;
use std::path::Path;
let parsed_pattern = ParsedPattern::new(&Path::new("src/te*.*"));
let file_name = String::from("test.txt");
let fragments:Vec<String> = parsed_pattern.match_to_pattern(&file_name).unwrap();
pub fn get_directory(&self) -> &PathBuf
Trait Implementations§
Source§impl Debug for ParsedPattern
impl Debug for ParsedPattern
Source§impl PartialEq for ParsedPattern
impl PartialEq for ParsedPattern
impl StructuralPartialEq for ParsedPattern
Auto Trait Implementations§
impl Freeze for ParsedPattern
impl RefUnwindSafe for ParsedPattern
impl Send for ParsedPattern
impl Sync for ParsedPattern
impl Unpin for ParsedPattern
impl UnwindSafe for ParsedPattern
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more