use haste_fhir_operation_error::OperationOutcomeError;
use std::{future::Future, pin::Pin};
pub struct Secret(Vec<u8>);
impl Secret {
pub fn new(bytes: Vec<u8>) -> Self {
Self(bytes)
}
pub fn expose_bytes(&self) -> &[u8] {
&self.0
}
}
impl std::fmt::Debug for Secret {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("Secret(REDACTED)")
}
}
pub trait SecretsProvider: Sync + Send {
fn get_secret<'a>(
&'a self,
name: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Secret, OperationOutcomeError>> + Send + 'a>>;
}
pub trait Encryptor: Sync + Send {
fn encrypt(&self, plaintext: &[u8]) -> Result<Vec<u8>, OperationOutcomeError>;
fn decrypt(&self, ciphertext: &[u8]) -> Result<Vec<u8>, OperationOutcomeError>;
}