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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use Result;
use NaiveDateTime;
use crateFileNameToDateTransformer;
/// This function tries to retrieve a file creation date and time from a file name.
///
/// The function accepts a list of `NameTransformer` instances that are used to match and transform the file name into a datetime.
/// Each `NameTransformer` instance contains a regular expression and a transformation function.
/// A list of standard `NameTransformer` instances can be generated using the `NameTransformer::get_standard_name_parsers` function.
///
/// # Arguments
///
/// * `name` - A reference to a string that represents the file name.
/// * `parsers` - A reference to a vector of `NameTransformer` instances.
///
/// # Returns
///
/// * `Result<Option<(NaiveDateTime, String)>>` - A `Result` that, if `Ok`, contains an `Option` with a tuple.
/// The first element of the tuple is the date and time from the file name.
/// The second element of the tuple is the file name with the matched part removed.
/// If the date and time could not be retrieved, the `Option` will be `None`.
/// If an error occurred during the process, the `Result` will be `Err`.
///
/// # Errors
///
/// This function will return an error if:
///
/// * A transformation function failed and errors