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
use blue_archive::{enums::School, fetcher::StudentFetcher, types::students::Age, Language};
#[allow(unused_variables)]
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// In this example, we will see two different ways of filtering.
// We can fetch all students first on their own...
// For this one, we will use Chinese.
let students = blue_archive::fetch_all_students(Language::Chinese).await?;
// We will also create a fetcher for later use.
let fetcher = StudentFetcher::new(Language::Chinese).await?;
// And now, let us fetch 17 year olds under the Trinity General School.
// First, let us try with the filter function.
let trinity_17 = blue_archive::filter(&students)
.apply(Age(Some(17)))
.apply(School::Trinity)
.finish();
// And now, let us fetch the same thing using the student fetcher.
// The implementations are relatively identical.
let trinity_17 = (fetcher.filter())
.apply(Age(Some(17)))
.apply(School::Trinity)
.finish();
// Let us print out all the filtered students.
println!(
"|:: Age 17 & {} : [{}/{}]",
School::Trinity.full_name(),
trinity_17.len(),
students.len(),
);
trinity_17.iter().for_each(|student| println!("{student}"));
// There are way more implementations then shown. You can also implement your own using the StudentFilter if you want!
Ok(())
}