Rest/Fn/Binary/Command/Sequential.rs
1/// Asynchronously processes entries to generate summaries and outputs the
2/// results sequentially.
3///
4/// This function performs the following steps:
5/// 1. Filters and processes the provided entries based on the given pattern and
6/// separator.
7/// 2. Spawns asynchronous tasks to generate summaries for each entry.
8/// 3. Collects the results and outputs them.
9///
10/// # Argument
11///
12/// * `Option` - A struct containing the following fields:
13/// - `Entry`: A vector of vectors, where each inner vector contains the
14/// components of a file path.
15/// - `Separator`: A character used to join the components of the file path.
16/// - `Pattern`: A string pattern to match against the last element of each
17/// entry.
18///
19/// # Example
20///
21/// ```rust
22/// let options = Option {
23/// Entry:vec![vec!["path".to_string(), "to".to_string(), "file.git".to_string()]],
24/// Separator:'/',
25/// Pattern:".git".to_string(),
26/// };
27/// Fn(options).await;
28/// ```
29///
30/// # Errors
31///
32/// This function will log errors if it fails to generate summaries or send
33/// results.
34pub async fn Fn(Option { Entry, Pattern, Separator, .. }:Option) {
35 let Queue = futures::future::join_all(
36 Entry
37 .into_iter()
38 .filter_map(|Entry| {
39 Entry
40 .last()
41 .filter(|Last| *Last == &Pattern)
42 .map(|_| Entry[0..Entry.len() - 1].join(&Separator.to_string()))
43 })
44 .map(|Entry| {
45 async move {
46 match crate::Fn::Build::Fn(&Entry).await {
47 Ok(Build) => Ok((Entry, format!("{:?}", Build))),
48
49 Err(_Error) => Err(format!("Error generating summary for {}: {}", Entry, _Error)),
50 }
51 }
52 }),
53 )
54 .await;
55
56 crate::Fn::Build::Group::Fn(Queue.into_iter().filter_map(Result::ok).collect::<Vec<_>>());
57}
58
59use crate::Struct::Binary::Command::Entry::Struct as Option;