use std::io::Write;
use data::LinkReference;
use super::{
policy::{UniquenessPolicy, UsagesPolicy},
CascadeUniquenessAndUsagesResolver, CascadeUsagesResolver, InnerReferenceExistenceValidator,
ItselfConstantToSelfReferenceResolver, LoggingDecorator, NoExceptionsDecorator,
NonExistentDependenciesCreator, NonNullContentsLinkDeletionResolver,
NullConstantToSelfReferenceResolver, UsagesValidator,
};
use crate::Doublets;
pub type AutomaticUniquenessAndUsagesResolution<T, L> = CascadeUniquenessAndUsagesResolver<
T,
NonNullContentsLinkDeletionResolver<T, CascadeUsagesResolver<T, L>>,
>;
pub trait DecoratorsExt<T: LinkReference>: Doublets<T> + Sized {
#[inline]
fn with_uniqueness<P: UniquenessPolicy>(self, _policy: P) -> P::Decorator<T, Self> {
P::decorate(self)
}
#[inline]
fn with_usages<P: UsagesPolicy>(self, _policy: P) -> P::Decorator<T, Self> {
P::decorate(self)
}
#[inline]
fn with_usages_validation(self) -> UsagesValidator<T, Self> {
UsagesValidator::new(self)
}
#[inline]
fn with_cascade_usages_resolution(self) -> CascadeUsagesResolver<T, Self> {
CascadeUsagesResolver::new(self)
}
#[inline]
fn with_inner_reference_existence_validation(
self,
) -> InnerReferenceExistenceValidator<T, Self> {
InnerReferenceExistenceValidator::new(self)
}
#[inline]
fn with_non_existent_dependencies_creation(self) -> NonExistentDependenciesCreator<T, Self> {
NonExistentDependenciesCreator::new(self)
}
#[inline]
fn with_itself_constant_resolution(self) -> ItselfConstantToSelfReferenceResolver<T, Self> {
ItselfConstantToSelfReferenceResolver::new(self)
}
#[inline]
fn with_null_constant_resolution(self) -> NullConstantToSelfReferenceResolver<T, Self> {
NullConstantToSelfReferenceResolver::new(self)
}
#[inline]
fn with_non_null_contents_deletion_resolution(
self,
) -> NonNullContentsLinkDeletionResolver<T, Self> {
NonNullContentsLinkDeletionResolver::new(self)
}
#[inline]
fn with_logging<W: Write + Send + Sync>(self, writer: W) -> LoggingDecorator<T, Self, W> {
LoggingDecorator::new(self, writer)
}
#[inline]
fn with_no_exceptions(self) -> NoExceptionsDecorator<T, Self> {
NoExceptionsDecorator::new(self)
}
#[inline]
fn with_automatic_uniqueness_and_usages_resolution(
self,
) -> AutomaticUniquenessAndUsagesResolution<T, Self> {
CascadeUniquenessAndUsagesResolver::new(NonNullContentsLinkDeletionResolver::new(
CascadeUsagesResolver::new(self),
))
}
}
impl<T: LinkReference, L: Doublets<T>> DecoratorsExt<T> for L {}