pub struct LoggingDecorator<T: LinkReference, L: Doublets<T>, W: Write + Send + Sync> { /* private fields */ }Expand description
Logs every create, update and delete to a writer, in the format C#
LoggingDecorator uses.
Each mutation appends one line, for example:
Create. Before: (0->0). After: (3: 0->0)
Update. Before: (3: 0->0). After: (3: 1->2)
Delete. Before: (3: 1->2). After: (0->0)A callback’s Flow::Break suppresses later user callbacks while completed
mutations continue to be logged. The break is returned once the operation finishes.
§Deviation from C#
C# writes to an auto-flushing StreamWriter and drops I/O errors. This port keeps the
first I/O error and returns it as Error::AllocFailed once the operation finishes,
so a broken log cannot pass unnoticed. Wrap the writer in a
BufWriter if you want C#’s buffering behaviour, and flush it
yourself.
Implementations§
Source§impl<T: LinkReference, L: Doublets<T>, W: Write + Send + Sync> LoggingDecorator<T, L, W>
impl<T: LinkReference, L: Doublets<T>, W: Write + Send + Sync> LoggingDecorator<T, L, W>
Sourcepub const fn new(links: L, writer: W) -> Self
pub const fn new(links: L, writer: W) -> Self
Wraps links so that every mutation is logged to writer.
Sourcepub const fn writer_mut(&mut self) -> &mut W
pub const fn writer_mut(&mut self) -> &mut W
Returns a mutable reference to the log writer.
Sourcepub fn into_inner(self) -> (L, W)
pub fn into_inner(self) -> (L, W)
Unwraps the decorator and returns the wrapped store and the log writer.
Trait Implementations§
Source§impl<T: LinkReference, L: Doublets<T> + Debug, W: Write + Send + Sync> Debug for LoggingDecorator<T, L, W>
impl<T: LinkReference, L: Doublets<T> + Debug, W: Write + Send + Sync> Debug for LoggingDecorator<T, L, W>
Source§impl<T: LinkReference, L: Doublets<T>, W: Write + Send + Sync> Doublets<T> for LoggingDecorator<T, L, W>
impl<T: LinkReference, L: Doublets<T>, W: Write + Send + Sync> Doublets<T> for LoggingDecorator<T, L, W>
Source§fn get_link(&self, index: T) -> Option<Link<T>>
fn get_link(&self, index: T) -> Option<Link<T>>
index, or None if it does not exist.Source§fn count_by(&self, query: impl ToQuery<T>) -> Twhere
Self: Sized,
fn count_by(&self, query: impl ToQuery<T>) -> Twhere
Self: Sized,
query.Source§fn create_by_with<F>(
&mut self,
query: impl ToQuery<T>,
handler: F,
) -> Result<Flow, Error<T>>
fn create_by_with<F>( &mut self, query: impl ToQuery<T>, handler: F, ) -> Result<Flow, Error<T>>
query, calling handler on each created link.Source§fn create_by(&mut self, query: impl ToQuery<T>) -> Result<T, Error<T>>where
Self: Sized,
fn create_by(&mut self, query: impl ToQuery<T>) -> Result<T, Error<T>>where
Self: Sized,
query and returns its index.Source§fn create_with<F>(&mut self, handler: F) -> Result<Flow, Error<T>>
fn create_with<F>(&mut self, handler: F) -> Result<Flow, Error<T>>
handler with the before/after states.Source§fn create(&mut self) -> Result<T, Error<T>>where
Self: Sized,
fn create(&mut self) -> Result<T, Error<T>>where
Self: Sized,
Source§fn each_by<F>(&self, query: impl ToQuery<T>, handler: F) -> Flow
fn each_by<F>(&self, query: impl ToQuery<T>, handler: F) -> Flow
query, calling handler for each.Source§fn each<F>(&self, handler: F) -> Flow
fn each<F>(&self, handler: F) -> Flow
handler for each.Source§fn update_by_with<H>(
&mut self,
query: impl ToQuery<T>,
change: impl ToQuery<T>,
handler: H,
) -> Result<Flow, Error<T>>
fn update_by_with<H>( &mut self, query: impl ToQuery<T>, change: impl ToQuery<T>, handler: H, ) -> Result<Flow, Error<T>>
query to change, calling handler with before/after.Source§fn update_by(
&mut self,
query: impl ToQuery<T>,
change: impl ToQuery<T>,
) -> Result<T, Error<T>>where
Self: Sized,
fn update_by(
&mut self,
query: impl ToQuery<T>,
change: impl ToQuery<T>,
) -> Result<T, Error<T>>where
Self: Sized,
query to change and returns the updated link’s index.Source§fn update_with<F>(
&mut self,
index: T,
source: T,
target: T,
handler: F,
) -> Result<Flow, Error<T>>
fn update_with<F>( &mut self, index: T, source: T, target: T, handler: F, ) -> Result<Flow, Error<T>>
index to (index, source, target), calling handler.Source§fn update(&mut self, index: T, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
fn update(&mut self, index: T, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
index to (index, source, target) and returns the index.Source§fn delete_by_with<F>(
&mut self,
query: impl ToQuery<T>,
handler: F,
) -> Result<Flow, Error<T>>
fn delete_by_with<F>( &mut self, query: impl ToQuery<T>, handler: F, ) -> Result<Flow, Error<T>>
query, calling handler with before/after states.Source§fn delete_by(&mut self, query: impl ToQuery<T>) -> Result<T, Error<T>>where
Self: Sized,
fn delete_by(&mut self, query: impl ToQuery<T>) -> Result<T, Error<T>>where
Self: Sized,
query and returns the deleted link’s index.Source§fn delete_with<F>(&mut self, index: T, handler: F) -> Result<Flow, Error<T>>
fn delete_with<F>(&mut self, index: T, handler: F) -> Result<Flow, Error<T>>
index, calling handler with before/after states.Source§fn delete(&mut self, index: T) -> Result<T, Error<T>>where
Self: Sized,
fn delete(&mut self, index: T) -> Result<T, Error<T>>where
Self: Sized,
index and returns its former index.Source§fn try_get_link(&self, index: T) -> Result<Link<T>, Error<T>>
fn try_get_link(&self, index: T) -> Result<Link<T>, Error<T>>
index, or Err(Error::NotExists) if it does not exist.Source§fn delete_all(&mut self) -> Result<(), Error<T>>where
Self: Sized,
fn delete_all(&mut self) -> Result<(), Error<T>>where
Self: Sized,
Source§fn delete_query_with<F>(
&mut self,
query: impl ToQuery<T>,
handler: F,
) -> Result<(), Error<T>>
fn delete_query_with<F>( &mut self, query: impl ToQuery<T>, handler: F, ) -> Result<(), Error<T>>
query, calling handler for each deletion.
Duplicate matches are deleted once, in reverse order of their first occurrence.Source§fn delete_usages_with<F>(
&mut self,
index: T,
handler: F,
) -> Result<(), Error<T>>
fn delete_usages_with<F>( &mut self, index: T, handler: F, ) -> Result<(), Error<T>>
index as a source or target once,
calling handler for each deletion.Source§fn delete_usages(&mut self, index: T) -> Result<(), Error<T>>where
Self: Sized,
fn delete_usages(&mut self, index: T) -> Result<(), Error<T>>where
Self: Sized,
index as a source or target.Source§fn create_point(&mut self) -> Result<T, Error<T>>where
Self: Sized,
fn create_point(&mut self) -> Result<T, Error<T>>where
Self: Sized,
Source§fn create_link_with<F>(
&mut self,
source: T,
target: T,
handler: F,
) -> Result<Flow, Error<T>>
fn create_link_with<F>( &mut self, source: T, target: T, handler: F, ) -> Result<Flow, Error<T>>
Source§fn create_link(&mut self, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
fn create_link(&mut self, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
source to target and returns its index.Source§fn found(&self, query: impl ToQuery<T>) -> boolwhere
Self: Sized,
fn found(&self, query: impl ToQuery<T>) -> boolwhere
Self: Sized,
true if at least one link matches query.Source§fn find(&self, query: impl ToQuery<T>) -> Option<Link<T>>where
Self: Sized,
fn find(&self, query: impl ToQuery<T>) -> Option<Link<T>>where
Self: Sized,
query, or None.Source§fn search(&self, source: T, target: T) -> Option<T>where
Self: Sized,
fn search(&self, source: T, target: T) -> Option<T>where
Self: Sized,
source and target, or None.Source§fn search_or(&self, source: T, target: T, default: T) -> Twhere
Self: Sized,
fn search_or(&self, source: T, target: T, default: T) -> Twhere
Self: Sized,
use search instead
Source§fn single(&self, query: impl ToQuery<T>) -> Option<Link<T>>where
Self: Sized,
fn single(&self, query: impl ToQuery<T>) -> Option<Link<T>>where
Self: Sized,
query only if exactly one link matches; None otherwise.Source§fn get_or_create(&mut self, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
fn get_or_create(&mut self, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
(source, target) link, creating it if it does not exist.Source§fn count_usages(&self, index: T) -> Result<T, Error<T>>where
Self: Sized,
fn count_usages(&self, index: T) -> Result<T, Error<T>>where
Self: Sized,
index as a source or target.Source§fn usages(&self, index: T) -> Result<Vec<T>, Error<T>>where
Self: Sized,
fn usages(&self, index: T) -> Result<Vec<T>, Error<T>>where
Self: Sized,
index as a source or target.Source§fn exist(&self, link: T) -> boolwhere
Self: Sized,
fn exist(&self, link: T) -> boolwhere
Self: Sized,
true if the link at link exists (internal or external).Source§fn has_usages(&self, link: T) -> boolwhere
Self: Sized,
fn has_usages(&self, link: T) -> boolwhere
Self: Sized,
true if any other link references link as a source or target.Source§impl<T: LinkReference, L: Doublets<T>, W: Write + Send + Sync> Links<T> for LoggingDecorator<T, L, W>
impl<T: LinkReference, L: Doublets<T>, W: Write + Send + Sync> Links<T> for LoggingDecorator<T, L, W>
Source§fn constants(&self) -> &LinksConstants<T>
fn constants(&self) -> &LinksConstants<T>
LinksConstants (any/null/range values).Source§fn count_links(&self, query: &[T]) -> T
fn count_links(&self, query: &[T]) -> T
query.Source§fn each_links(&self, query: &[T], handler: ReadHandler<'_, T>) -> Flow
fn each_links(&self, query: &[T], handler: ReadHandler<'_, T>) -> Flow
query, calling handler for each.Source§fn create_links(
&mut self,
query: &[T],
handler: WriteHandler<'_, T>,
) -> Result<Flow, Error<T>>
fn create_links( &mut self, query: &[T], handler: WriteHandler<'_, T>, ) -> Result<Flow, Error<T>>
query and reports each creation via handler.Source§fn update_links(
&mut self,
query: &[T],
change: &[T],
handler: WriteHandler<'_, T>,
) -> Result<Flow, Error<T>>
fn update_links( &mut self, query: &[T], change: &[T], handler: WriteHandler<'_, T>, ) -> Result<Flow, Error<T>>
query to the new values in change, reporting via handler.Source§fn delete_links(
&mut self,
query: &[T],
handler: WriteHandler<'_, T>,
) -> Result<Flow, Error<T>>
fn delete_links( &mut self, query: &[T], handler: WriteHandler<'_, T>, ) -> Result<Flow, Error<T>>
Auto Trait Implementations§
impl<T, L, W> Freeze for LoggingDecorator<T, L, W>
impl<T, L, W> RefUnwindSafe for LoggingDecorator<T, L, W>
impl<T, L, W> Send for LoggingDecorator<T, L, W>
impl<T, L, W> Sync for LoggingDecorator<T, L, W>
impl<T, L, W> Unpin for LoggingDecorator<T, L, W>
impl<T, L, W> UnsafeUnpin for LoggingDecorator<T, L, W>
impl<T, L, W> UnwindSafe for LoggingDecorator<T, L, W>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, L> DecoratorsExt<T> for Lwhere
T: LinkReference,
L: Doublets<T>,
impl<T, L> DecoratorsExt<T> for Lwhere
T: LinkReference,
L: Doublets<T>,
Source§fn with_transactions<J: TransitionLog<T>>(
self,
journal: J,
) -> Result<TransactionsDecorator<T, Self, J>, Error<T>>
fn with_transactions<J: TransitionLog<T>>( self, journal: J, ) -> Result<TransactionsDecorator<T, Self, J>, Error<T>>
TransactionsDecorator and recovers its journal.Source§fn with_uniqueness<P: UniquenessPolicy>(
self,
_policy: P,
) -> P::Decorator<T, Self>
fn with_uniqueness<P: UniquenessPolicy>( self, _policy: P, ) -> P::Decorator<T, Self>
Source§fn with_usages<P: UsagesPolicy>(self, _policy: P) -> P::Decorator<T, Self>
fn with_usages<P: UsagesPolicy>(self, _policy: P) -> P::Decorator<T, Self>
Source§fn with_usages_validation(self) -> UsagesValidator<T, Self>
fn with_usages_validation(self) -> UsagesValidator<T, Self>
UsagesValidator.Source§fn with_cascade_usages_resolution(self) -> CascadeUsagesResolver<T, Self>
fn with_cascade_usages_resolution(self) -> CascadeUsagesResolver<T, Self>
CascadeUsagesResolver.Source§fn with_inner_reference_existence_validation(
self,
) -> InnerReferenceExistenceValidator<T, Self>
fn with_inner_reference_existence_validation( self, ) -> InnerReferenceExistenceValidator<T, Self>
InnerReferenceExistenceValidator.Source§fn with_non_existent_dependencies_creation(
self,
) -> NonExistentDependenciesCreator<T, Self>
fn with_non_existent_dependencies_creation( self, ) -> NonExistentDependenciesCreator<T, Self>
NonExistentDependenciesCreator.Source§fn with_non_existent_deletion_resolution(
self,
) -> NonExistentDeletionResolver<T, Self>
fn with_non_existent_deletion_resolution( self, ) -> NonExistentDeletionResolver<T, Self>
NonExistentDeletionResolver, ignoring deletion of missing links.Source§fn with_itself_constant_resolution(
self,
) -> ItselfConstantToSelfReferenceResolver<T, Self>
fn with_itself_constant_resolution( self, ) -> ItselfConstantToSelfReferenceResolver<T, Self>
ItselfConstantToSelfReferenceResolver.Source§fn with_null_constant_resolution(
self,
) -> NullConstantToSelfReferenceResolver<T, Self>
fn with_null_constant_resolution( self, ) -> NullConstantToSelfReferenceResolver<T, Self>
NullConstantToSelfReferenceResolver.Source§fn with_non_null_contents_deletion_resolution(
self,
) -> NonNullContentsLinkDeletionResolver<T, Self>
fn with_non_null_contents_deletion_resolution( self, ) -> NonNullContentsLinkDeletionResolver<T, Self>
NonNullContentsLinkDeletionResolver.Source§fn with_logging<W: Write + Send + Sync>(
self,
writer: W,
) -> LoggingDecorator<T, Self, W>
fn with_logging<W: Write + Send + Sync>( self, writer: W, ) -> LoggingDecorator<T, Self, W>
LoggingDecorator, logging every mutation to writer.Source§fn with_no_exceptions(self) -> NoExceptionsDecorator<T, Self>
fn with_no_exceptions(self) -> NoExceptionsDecorator<T, Self>
NoExceptionsDecorator.Source§fn with_automatic_uniqueness_and_usages_resolution(
self,
) -> AutomaticUniquenessAndUsagesResolution<T, Self>
fn with_automatic_uniqueness_and_usages_resolution( self, ) -> AutomaticUniquenessAndUsagesResolution<T, Self>
ILinksExtensions.DecorateWithAutomaticUniquenessAndUsagesResolution:
CascadeUsagesResolver innermost, then NonNullContentsLinkDeletionResolver,
then CascadeUniquenessAndUsagesResolver outermost.
The cascade explicitly resets each nested usage before descending, so handlers
observe resets before the corresponding deletions, as with C#’s facade recursion. Read moreSource§impl<T, All> DoubletsExt<T> for Allwhere
T: LinkReference,
All: Doublets<T>,
impl<T, All> DoubletsExt<T> for Allwhere
T: LinkReference,
All: Doublets<T>,
Source§fn iter(
&self,
) -> impl Iterator<Item = Link<T>> + ExactSizeIterator + DoubleEndedIterator
fn iter( &self, ) -> impl Iterator<Item = Link<T>> + ExactSizeIterator + DoubleEndedIterator
Source§fn each_iter(
&self,
query: impl ToQuery<T>,
) -> impl Iterator<Item = Link<T>> + ExactSizeIterator + DoubleEndedIterator
fn each_iter( &self, query: impl ToQuery<T>, ) -> impl Iterator<Item = Link<T>> + ExactSizeIterator + DoubleEndedIterator
query.