spacetraders-client 0.1.0

Async Rust client for the SpaceTraders API v2 with priority-aware rate limiting and retry
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::sync::atomic::{AtomicU64, Ordering};

pub(crate) static REQUESTS_TOTAL: AtomicU64 = AtomicU64::new(0);
pub(crate) static LOW_PRIORITY_DEFERRED_TOTAL: AtomicU64 = AtomicU64::new(0);

#[derive(Clone, Copy, Debug)]
pub struct RequestActivitySnapshot {
    pub requests_total: u64,
    pub low_priority_deferred_total: u64,
}

pub fn request_activity_snapshot() -> RequestActivitySnapshot {
    RequestActivitySnapshot {
        requests_total: REQUESTS_TOTAL.load(Ordering::Relaxed),
        low_priority_deferred_total: LOW_PRIORITY_DEFERRED_TOTAL.load(Ordering::Relaxed),
    }
}