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 implementationArcConsumer<T>: Arc-based thread-safe shared ownership implementationRcConsumer<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§
- ArcConditional
Consumer - ArcConditionalConsumer struct
- ArcConsumer
- ArcConsumer struct
- BoxConditional
Consumer - BoxConditionalConsumer struct
- BoxConsumer
- BoxConsumer struct
- RcConditional
Consumer - RcConditionalConsumer struct
- RcConsumer
- RcConsumer struct
Traits§
- Consumer
- Consumer trait - Unified non-mutating consumer interface
- FnConsumer
Ops - Extension trait providing non-mutating consumer composition methods for closures