use crate::PreimageKey;
use alloc::{boxed::Box, string::String, vec::Vec};
use anyhow::Result;
use async_trait::async_trait;
use core::future::Future;
#[async_trait]
pub trait PreimageOracleClient {
async fn get(&self, key: PreimageKey) -> Result<Vec<u8>>;
async fn get_exact(&self, key: PreimageKey, buf: &mut [u8]) -> Result<()>;
}
#[async_trait]
pub trait HintWriterClient {
async fn write(&self, hint: &str) -> Result<()>;
}
#[async_trait]
pub trait PreimageOracleServer {
async fn next_preimage_request<F, Fut>(&self, get_preimage: F) -> Result<()>
where
F: FnMut(PreimageKey) -> Fut + Send,
Fut: Future<Output = Result<Vec<u8>>> + Send;
}
#[async_trait]
pub trait HintReaderServer {
async fn next_hint<F, Fut>(&self, route_hint: F) -> Result<()>
where
F: FnMut(String) -> Fut + Send,
Fut: Future<Output = Result<()>> + Send;
}