meteroid-rs 0.31.4

Official Rust SDK for Meteroid, the open-source billing platform: subscriptions, invoicing, usage-based billing and webhooks.
Documentation
// this file is @generated by Perseid; edit the shared runtime template.
//! Settings of a single call, over the client's.
use std::time::Duration;

/// Settings of the calls made through a resource, over the client options:
/// `client.items().with_options(RequestOptions::new().max_retries(0))`.
#[derive(Clone, Debug, Default)]
pub struct RequestOptions {
    pub(crate) headers: Vec<(String, String)>,
    #[allow(clippy::option_option)]
    pub(crate) timeout: Option<Option<Duration>>,
    pub(crate) max_retries: Option<u32>,
    pub(crate) idempotency_key: Option<String>,
}

impl RequestOptions {
    /// Options changing nothing.
    #[must_use]
    pub fn new() -> Self {
        Self::default()
    }

    /// Adds a header, replacing one the client would send under that name.
    #[must_use]
    pub fn header(mut self, name: impl Into<String>, value: impl Into<String>) -> Self {
        self.headers.push((name.into(), value.into()));
        self
    }

    /// Timeout of each attempt; `None` never times out.
    #[must_use]
    pub fn timeout(mut self, timeout: impl Into<Option<Duration>>) -> Self {
        self.timeout = Some(timeout.into());
        self
    }

    /// How many times a failed request is retried, overriding the client's `max_retries`.
    #[must_use]
    pub fn max_retries(mut self, max_retries: u32) -> Self {
        self.max_retries = Some(max_retries);
        self
    }

    /// The `Idempotency-Key` header, which also makes a POST request safe to retry.
    #[must_use]
    pub fn idempotency_key(mut self, key: impl Into<String>) -> Self {
        self.idempotency_key = Some(key.into());
        self
    }
}