doublets/decorators/
builder.rs1use std::io::Write;
4
5use data::LinkReference;
6
7use super::{
8 policy::{UniquenessPolicy, UsagesPolicy},
9 CascadeUniquenessAndUsagesResolver, CascadeUsagesResolver, InnerReferenceExistenceValidator,
10 ItselfConstantToSelfReferenceResolver, LoggingDecorator, NoExceptionsDecorator,
11 NonExistentDependenciesCreator, NonNullContentsLinkDeletionResolver,
12 NullConstantToSelfReferenceResolver, UsagesValidator,
13};
14use crate::Doublets;
15
16pub type AutomaticUniquenessAndUsagesResolution<T, L> = CascadeUniquenessAndUsagesResolver<
19 T,
20 NonNullContentsLinkDeletionResolver<T, CascadeUsagesResolver<T, L>>,
21>;
22
23pub trait DecoratorsExt<T: LinkReference>: Doublets<T> + Sized {
44 #[inline]
47 fn with_uniqueness<P: UniquenessPolicy>(self, _policy: P) -> P::Decorator<T, Self> {
48 P::decorate(self)
49 }
50
51 #[inline]
54 fn with_usages<P: UsagesPolicy>(self, _policy: P) -> P::Decorator<T, Self> {
55 P::decorate(self)
56 }
57
58 #[inline]
60 fn with_usages_validation(self) -> UsagesValidator<T, Self> {
61 UsagesValidator::new(self)
62 }
63
64 #[inline]
66 fn with_cascade_usages_resolution(self) -> CascadeUsagesResolver<T, Self> {
67 CascadeUsagesResolver::new(self)
68 }
69
70 #[inline]
72 fn with_inner_reference_existence_validation(
73 self,
74 ) -> InnerReferenceExistenceValidator<T, Self> {
75 InnerReferenceExistenceValidator::new(self)
76 }
77
78 #[inline]
80 fn with_non_existent_dependencies_creation(self) -> NonExistentDependenciesCreator<T, Self> {
81 NonExistentDependenciesCreator::new(self)
82 }
83
84 #[inline]
86 fn with_itself_constant_resolution(self) -> ItselfConstantToSelfReferenceResolver<T, Self> {
87 ItselfConstantToSelfReferenceResolver::new(self)
88 }
89
90 #[inline]
92 fn with_null_constant_resolution(self) -> NullConstantToSelfReferenceResolver<T, Self> {
93 NullConstantToSelfReferenceResolver::new(self)
94 }
95
96 #[inline]
98 fn with_non_null_contents_deletion_resolution(
99 self,
100 ) -> NonNullContentsLinkDeletionResolver<T, Self> {
101 NonNullContentsLinkDeletionResolver::new(self)
102 }
103
104 #[inline]
106 fn with_logging<W: Write + Send + Sync>(self, writer: W) -> LoggingDecorator<T, Self, W> {
107 LoggingDecorator::new(self, writer)
108 }
109
110 #[inline]
112 fn with_no_exceptions(self) -> NoExceptionsDecorator<T, Self> {
113 NoExceptionsDecorator::new(self)
114 }
115
116 #[inline]
121 fn with_automatic_uniqueness_and_usages_resolution(
122 self,
123 ) -> AutomaticUniquenessAndUsagesResolution<T, Self> {
124 CascadeUniquenessAndUsagesResolver::new(NonNullContentsLinkDeletionResolver::new(
125 CascadeUsagesResolver::new(self),
126 ))
127 }
128}
129
130impl<T: LinkReference, L: Doublets<T>> DecoratorsExt<T> for L {}