qstash-rs 0.6.0

A Rust SDK for Upstash QStash
Documentation
use reqwest::Method;
use serde::{Deserialize, Serialize};

use super::Client;
use crate::error::Result;

/// Current and next QStash signing keys.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SigningKeys {
    /// Current signing key.
    pub current: String,
    /// Next signing key.
    pub next: String,
}

/// Signing-key operations.
pub struct SigningKeysApi<'a> {
    pub(crate) client: &'a Client,
}

impl SigningKeysApi<'_> {
    /// Retrieves the current and next signing keys.
    pub async fn get(&self) -> Result<SigningKeys> {
        self.client
            .http
            .send_json(Method::GET, "v2/keys", &[], None, None)
            .await
    }

    /// Rotates the signing keys.
    pub async fn rotate(&self) -> Result<SigningKeys> {
        self.client
            .http
            .send_json(Method::POST, "v2/keys/rotate", &[], None, None)
            .await
    }
}