erebus-sdk-rust 1.4.0

Erebus SDK for Rust
Documentation
mod pool;
mod global;
mod client;
mod types;

pub use types::{
    ErebusRequestType,
    ObjectCacheRequest,
    UrlCacheRequest,
    ErebusPackedRequest,
    ErebusResponse,
    ObjectCacheResponse,
    UrlCacheResponse,
};

use futures_util::{SinkExt, StreamExt};
use serde::{Deserialize, Serialize};
use std::future::Future;
use serde::de::DeserializeOwned;

pub async fn object_cache_get<T: Serialize + DeserializeOwned + ?Sized>(
    name: String,
    tags: Vec<String>,
) -> Result<Option<T>, Box<dyn std::error::Error>> {
    let x = global::EREBUS_CACHE_POOL.get_instance();
    let mut y = x.lock().await;

    y.object_cache::<T>(
        name,
        tags,
        None,
    ).await
}

pub async fn object_cache_put<T: Serialize + DeserializeOwned + ?Sized>(
    name: String,
    tags: Vec<String>,
    body: T,
) -> Result<Option<T>, Box<dyn std::error::Error>> {
    let x = global::EREBUS_CACHE_POOL.get_instance();
    let mut y = x.lock().await;

    y.object_cache::<T>(
        name,
        tags,
        Some(body),
    ).await
}

pub async fn url_cache(
    request: UrlCacheRequest,
) -> Result<UrlCacheResponse, Box<dyn std::error::Error>> {
    let x = global::EREBUS_CACHE_POOL.get_instance();
    let mut y = x.lock().await;

    y.url_cache(request).await
}