cairo-language-server 2.19.0-rc.2

The Cairo Language Server
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::sync::atomic::{AtomicU64, Ordering};

use scarb_proc_macro_server_types::jsonrpc::RequestId;

/// Atomic Id generator.
#[derive(Debug, Default)]
pub struct IdGenerator {
    counter: AtomicU64,
}

impl IdGenerator {
    /// Every call to this method returns different ID, but order is not guaranteed.
    pub fn unique_id(&self) -> RequestId {
        self.counter.fetch_add(1, Ordering::Relaxed)
    }
}