use std::fmt::Display;
use std::sync::Arc;
use crate::core::{Container, Resolver};
use super::ItemSet;
pub trait Collection: Send + Sync + 'static {
type Value: Clone + Eq + Display + Send + Sync + 'static;
fn name() -> &'static str;
fn describe() -> &'static str {
Self::name()
}
}
pub trait Item: Send + Sync {
type CollectionType: Collection;
fn value(&self) -> <Self::CollectionType as Collection>::Value;
fn name(&self) -> &'static str;
fn description(&self) -> &'static str {
self.name()
}
}
pub type DynItem<C> = dyn Item<CollectionType = C> + Send + Sync;
#[doc(hidden)]
pub trait ItemList: Collection + Sized {
fn frozen_set() -> Arc<ItemSet<Self>>;
}
impl<C: ItemList> Resolver<ItemSet<C>> for Container {
fn resolve() -> Arc<ItemSet<C>> {
C::frozen_set()
}
}