spiral-sdk 0.1.10

Rust SDK for Spiral resource and table APIs
Documentation
// Generated by tools/service-contracts/rust.py. Do not edit.
#![doc = "Transport-independent service interface for local and remote calls."]

use async_trait::async_trait;
use spiral_contract::auth::AuthHeader;
use spiral_contract::call::CallError;

use crate::api::usage::objects::*;
/// Service implementations authenticate Authorization headers and enforce resource permissions.
#[async_trait]
pub trait UsageApi: Send + Sync + 'static {
    /// Accept a batch for asynchronous delivery. A successful response means the report passed
    /// authentication and authorization; delivery failures are logged and do not fail the request.
    async fn report_usage(
        &self,
        auth_header: AuthHeader,
        request: ReportUsageRequest,
    ) -> Result<(), CallError<UsageError>>;
    /// Record raw usage of a project. The caller needs read access to the project's Tables. An app
    /// that acts for a user needs the `tables:read` scope. A successful response means that the
    /// service received the batch. A request that does not match this contract, for example one
    /// with a measurement arm that this server does not know, fails as a whole with a 400, so a
    /// host must not fail its own work over this route. The service drops and counts a record that
    /// occurred too long ago or too far in the future and never fails the caller for one. It keeps
    /// records as structured telemetry and sends none of them to a billing system.
    async fn report_usage_records(
        &self,
        auth_header: AuthHeader,
        project_id: ProjectId,
        request: ReportUsageRecordsRequest,
    ) -> Result<(), CallError<UsageError>>;
}