spiral-sdk 0.1.10

Rust SDK for Spiral resource and table APIs
Documentation
//! Renewable storage compatibility for generated vector indexes operations.

use spiral_contract::call::CallError;
use uuid::Uuid;

use super::generated::vector_indexes::AuthenticatedClient;
pub use crate::api::vector_indexes::*;
/// Authenticated operations generated from the service contract.
pub type HttpVectorIndexClient = AuthenticatedClient;

impl AuthenticatedClient {
    /// Obtain a renewable binding, allowing older servers to fall back to storage access on 404.
    pub async fn storage_binding_optional(
        &self,
        vector_index_id: Uuid,
        request: StorageAccessRequest,
    ) -> Result<Option<StorageBinding>, CallError<VectorIndexesError>> {
        match self.storage_binding(vector_index_id, request).await {
            Ok(binding) => Ok(Some(binding)),
            Err(CallError::Service(error)) if error.status() == 404 => Ok(None),
            Err(CallError::UnknownRemote(error)) if error.status() == 404 => Ok(None),
            Err(error) => Err(error),
        }
    }
}