Module readonly_consumer

Module readonly_consumer 

Source
Expand description

§ReadonlyConsumer Types

Provides implementations of readonly consumer interfaces for executing operations that neither modify their own state nor modify input values.

This module provides a unified ReadonlyConsumer trait and three concrete implementations based on different ownership models:

  • BoxReadonlyConsumer<T>: Box-based single ownership implementation
  • ArcReadonlyConsumer<T>: Arc-based thread-safe shared ownership implementation
  • RcReadonlyConsumer<T>: Rc-based single-threaded shared ownership implementation

§Design Philosophy

ReadonlyConsumer uses Fn(&T) semantics, neither modifying its own state nor modifying input values. Suitable for pure observation, logging, notification and other scenarios. Compared to Consumer, ReadonlyConsumer does not require interior mutability (Mutex/RefCell), making it more efficient and easier to share.

§Author

Hu Haixing

Structs§

ArcReadonlyConsumer
ArcReadonlyConsumer struct
BoxReadonlyConsumer
BoxReadonlyConsumer struct
RcReadonlyConsumer
RcReadonlyConsumer struct

Traits§

FnReadonlyConsumerOps
Extension trait providing readonly consumer composition methods for closures
ReadonlyConsumer
ReadonlyConsumer trait - Unified readonly consumer interface