MCPcopy Create free account
hub / github.com/Rustixir/darkbird / main

Function main

example/Version-4.0.0 ( Materialized View )/example.rs:10–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8
9#[tokio::main]
10async fn main() {
11 let path = ".";
12 let storage_name = "blackbird";
13 let total_page_size = 1000;
14 let stype = StorageType::DiskCopies;
15
16 let ops = Options::new(path, storage_name, total_page_size, stype, true);
17 let storage = Storage::<Pid, User>::open(ops).await.unwrap();
18
19 // Generate
20 for num in 0..20 {
21 let id = format!("1234567{}", num);
22 let u = User {
23 name: "Danyalmhai".to_string(),
24 age: num % 24,
25 account_type: if (num% 25) > 18 { AccountType::Admin } else { AccountType::Guest },
26 access_level: if (num% 25) >= 23 { 1 } else { 3 }
27 };
28
29 storage.insert(id, u).await.unwrap();
30 }
31
32 let super_admins = storage.fetch_view("Super Admin");
33 let admins = storage.fetch_view("Admin");
34
35}
36
37type Pid = String;
38

Callers

nothing calls this directly

Calls 3

to_stringMethod · 0.45
insertMethod · 0.45
fetch_viewMethod · 0.45

Tested by

no test coverage detected