use std::sync::Arc;
use crate::{AgentId, BoxFut, Builder, Config, K2Result, SpaceId};
pub type DynBlocks = Arc<dyn Blocks>;
#[non_exhaustive]
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub enum BlockTarget {
Agent(AgentId),
}
pub trait Blocks: 'static + Send + Sync + std::fmt::Debug {
fn block(&self, target: BlockTarget) -> BoxFut<'static, K2Result<()>>;
fn is_blocked(
&self,
target: BlockTarget,
) -> BoxFut<'static, K2Result<bool>>;
fn is_any_blocked(
&self,
targets: Vec<BlockTarget>,
) -> BoxFut<'static, K2Result<bool>>;
}
pub type DynBlocksFactory = Arc<dyn BlocksFactory>;
pub trait BlocksFactory: 'static + Send + Sync + std::fmt::Debug {
fn default_config(&self, config: &mut Config) -> K2Result<()>;
fn validate_config(&self, config: &Config) -> K2Result<()>;
fn create(
&self,
builder: Arc<Builder>,
space_id: SpaceId,
) -> BoxFut<'static, K2Result<DynBlocks>>;
}