greentic_secrets_api/
lib.rs1#![cfg_attr(not(feature = "std"), no_std)]
2
3#[cfg(not(feature = "std"))]
4extern crate alloc;
5
6#[cfg(not(feature = "std"))]
7use alloc::{borrow::Cow, string::String, vec::Vec};
8#[cfg(feature = "std")]
9use std::{borrow::Cow, string::String, vec::Vec};
10
11use async_trait::async_trait;
12use thiserror::Error;
13
14#[cfg(feature = "std")]
15use anyhow::Error as AnyhowError;
16
17#[derive(Debug, Error)]
19pub enum SecretError {
20 #[error("not found: {0}")]
21 NotFound(String),
22
23 #[error("permission denied: {0}")]
24 Permission(String),
25
26 #[error("backend error: {0}")]
27 Backend(Cow<'static, str>),
28
29 #[cfg(feature = "std")]
30 #[error(transparent)]
31 Other(#[from] AnyhowError),
32}
33
34pub type Result<T> = core::result::Result<T, SecretError>;
36
37#[async_trait]
39pub trait SecretsManager: Send + Sync {
40 async fn read(&self, path: &str) -> Result<Vec<u8>>;
42
43 async fn write(&self, path: &str, bytes: &[u8]) -> Result<()>;
45
46 async fn delete(&self, path: &str) -> Result<()>;
48}