INNER CODE UNIT · Rust

ensure_client

zly2006/zhihu-plus-plus · aigc-vote-server/src/lib.rs:406

    fn ensure_client(&mut self, client_id: &str) {
        let now = now_epoch_seconds();
        self.clients
            .entry(client_id.to_string())
            .and_modify(|client| {
                client.last_seen_at = now;
            })
            .or_insert_with(|| ClientRecord {
                account: ClientAccount {
                    credit: INITIAL_CREDIT,
                    progress: 0,
                },
                last_seen_at: now,
            });
    }

    fn client_account(&self, client_id: &str) -> Result<ClientAccount, ServiceError> {
        self.clients

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…