Skip to main content

Module consumer

Module consumer 

Source
Expand description

§Consumer Types

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

It is similar to the Fn(&T) trait in the standard library.

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

  • BoxConsumer<T>: Box-based single ownership implementation
  • ArcConsumer<T>: Arc-based thread-safe shared ownership implementation
  • RcConsumer<T>: Rc-based single-threaded shared ownership implementation

§Design Philosophy

Consumer uses Fn(&T) semantics: it is invoked through &self and receives shared references to input values.

Suitable for pure observation, logging, notification and other scenarios. Compared to StatefulConsumer, Consumer does not require wrapper-level interior mutability (Mutex/RefCell), making it more efficient and easier to share.

§Author

Haixing Hu

Structs§

ArcConditionalConsumer
ArcConditionalConsumer struct
ArcConsumer
ArcConsumer struct
BoxConditionalConsumer
BoxConditionalConsumer struct
BoxConsumer
BoxConsumer struct
RcConditionalConsumer
RcConditionalConsumer struct
RcConsumer
RcConsumer struct

Traits§

Consumer
Consumer trait - Unified non-mutating consumer interface
FnConsumerOps
Extension trait providing non-mutating consumer composition methods for closures