1use baidu_netdisk_sdk::BaiduNetDiskClient;
2use log::info;
3
4#[tokio::main]
5async fn main() -> Result<(), Box<dyn std::error::Error>> {
6 env_logger::init();
7
8 println!("=== Baidu NetDisk Quota Test ===\n");
9
10 let client = BaiduNetDiskClient::builder().build()?;
11 info!("Client created successfully");
12
13 client.load_token_from_env()?;
14 info!("Token loaded successfully");
15
16 println!("1. Testing get_quota...");
17 let quota = client.quota().get_quota().await?;
18
19 println!("\n=== Basic Quota Information ===");
20 println!(
21 "Total: {}",
22 baidu_netdisk_sdk::CapacityInfo::format_bytes(quota.total)
23 );
24 println!(
25 "Used: {}",
26 baidu_netdisk_sdk::CapacityInfo::format_bytes(quota.used)
27 );
28 println!(
29 "Free: {}",
30 baidu_netdisk_sdk::CapacityInfo::format_bytes(quota.free)
31 );
32
33 println!("\n2. Testing get_quota_with_expire...");
34 let capacity = client.quota().get_quota_with_expire().await?;
35 println!("\n=== Detailed Capacity Information ===");
36 println!("Total: {}", capacity.format_total());
37 println!(
38 "Used: {} ({:.2}%)",
39 capacity.format_used(),
40 capacity.usage_percentage()
41 );
42 println!("Free: {}", capacity.format_free());
43 println!(
44 "Expired: {}",
45 if capacity.expire { "Yes" } else { "No" }
46 );
47
48 println!("\n3. Testing get_capacity (check_free only)...");
49 let capacity_free = client.quota().get_capacity(true, false).await?;
50
51 println!("\n=== Capacity with Free Check ===");
52 println!("Total: {}", capacity_free.format_total());
53 println!("Used: {}", capacity_free.format_used());
54 println!("Free: {}", capacity_free.format_free());
55
56 println!("\n4. Testing get_capacity (check_expire only)...");
57 let capacity_expire = client.quota().get_capacity(false, true).await?;
58
59 println!("\n=== Capacity with Expire Check ===");
60 println!("Total: {}", capacity_expire.format_total());
61 println!("Used: {}", capacity_expire.format_used());
62 println!(
63 "Expired: {}",
64 if capacity_expire.expire { "Yes" } else { "No" }
65 );
66
67 println!("\n=== All quota tests completed successfully ===");
68
69 Ok(())
70}