use std::sync::Arc;
use holochain_types::prelude::*;
use crate::CellRunner;
#[async_trait::async_trait]
#[mockall::automock]
#[allow(clippy::needless_lifetimes)]
pub trait AppStoreService: Send + Sync {
async fn get_dna_bundle(&self, dna_hash: DnaHash) -> AppStoreServiceResult<Option<DnaBundle>>;
async fn get_app_bundle(&self, app_hash: AppHash) -> AppStoreServiceResult<Option<AppBundle>>;
fn cell_ids<'a>(&'a self) -> std::collections::HashSet<&'a CellId>;
}
#[derive(thiserror::Error, Debug)]
pub enum AppStoreServiceError {}
pub type AppStoreServiceResult<T> = Result<T, AppStoreServiceError>;
pub enum AppHash {}
pub struct AppStoreBuiltin {
_runner: Arc<dyn CellRunner>,
_cell_id: CellId,
}
impl AppStoreBuiltin {
pub fn new(runner: Arc<impl CellRunner>, cell_id: CellId) -> Arc<Self> {
Arc::new(Self {
_runner: runner,
_cell_id: cell_id,
})
}
}
#[async_trait::async_trait]
#[allow(clippy::needless_lifetimes)]
impl AppStoreService for AppStoreBuiltin {
async fn get_dna_bundle(&self, _dna_hash: DnaHash) -> AppStoreServiceResult<Option<DnaBundle>> {
todo!("placeholder")
}
async fn get_app_bundle(&self, _app_hash: AppHash) -> AppStoreServiceResult<Option<AppBundle>> {
todo!("placeholder")
}
fn cell_ids<'a>(&'a self) -> std::collections::HashSet<&'a CellId> {
[&self._cell_id].into_iter().collect()
}
}
pub fn mock_app_store() -> MockAppStoreService {
let mut app_store = MockAppStoreService::new();
app_store
.expect_cell_ids()
.return_const(std::collections::HashSet::new());
app_store
}