pub struct ArcTransformer<T, R> { /* private fields */ }Expand description
ArcTransformer - thread-safe transformer wrapper
A thread-safe, clonable transformer wrapper suitable for multi-threaded scenarios. Can be called multiple times and shared across threads.
§Features
- Based on:
Arc<dyn Fn(T) -> R + Send + Sync> - Ownership: Shared ownership via reference counting
- Reusability: Can be called multiple times (each call consumes its input)
- Thread Safety: Thread-safe (
Send + Syncrequired) - Clonable: Cheap cloning via
Arc::clone
§Author
Haixing Hu
Implementations§
Source§impl<T, R> ArcTransformer<T, R>where
T: 'static,
R: 'static,
impl<T, R> ArcTransformer<T, R>where
T: 'static,
R: 'static,
Sourcepub fn new<F>(f: F) -> Self
pub fn new<F>(f: F) -> Self
Creates a new transformer.
Wraps the provided closure in the appropriate smart pointer type for this transformer implementation.
Sourcepub fn new_with_name<F>(name: &str, f: F) -> Self
pub fn new_with_name<F>(name: &str, f: F) -> Self
Creates a new named transformer.
Wraps the provided closure and assigns it a name, which is useful for debugging and logging purposes.
Sourcepub fn new_with_optional_name<F>(f: F, name: Option<String>) -> Self
pub fn new_with_optional_name<F>(f: F, name: Option<String>) -> Self
Creates a new named transformer with an optional name.
Wraps the provided closure and assigns it an optional name.
Sourcepub fn identity() -> ArcTransformer<T, T>
pub fn identity() -> ArcTransformer<T, T>
Creates an identity transformer.
Creates a transformer that returns the input value unchanged. Useful for default values or placeholder implementations.
§Returns
Returns a new transformer instance that returns the input unchanged.
pub fn when<P>(&self, predicate: P) -> ArcConditionalTransformer<T, R>
pub fn and_then<S, F>(&self, after: F) -> ArcTransformer<T, S>
Source§impl<T, R> ArcTransformer<T, R>
impl<T, R> ArcTransformer<T, R>
Trait Implementations§
Source§impl<T, R> Clone for ArcTransformer<T, R>
impl<T, R> Clone for ArcTransformer<T, R>
Source§impl<T, R> Debug for ArcTransformer<T, R>
impl<T, R> Debug for ArcTransformer<T, R>
Source§impl<T, R> Display for ArcTransformer<T, R>
impl<T, R> Display for ArcTransformer<T, R>
Source§impl<T, R> Transformer<T, R> for ArcTransformer<T, R>
impl<T, R> Transformer<T, R> for ArcTransformer<T, R>
Source§fn apply(&self, input: T) -> R
fn apply(&self, input: T) -> R
Source§fn into_box(self) -> BoxTransformer<T, R>where
T: 'static,
R: 'static,
fn into_box(self) -> BoxTransformer<T, R>where
T: 'static,
R: 'static,
Source§fn into_rc(self) -> RcTransformer<T, R>where
T: 'static,
R: 'static,
fn into_rc(self) -> RcTransformer<T, R>where
T: 'static,
R: 'static,
Source§fn into_arc(self) -> ArcTransformer<T, R>where
T: 'static,
R: 'static,
fn into_arc(self) -> ArcTransformer<T, R>where
T: 'static,
R: 'static,
Source§fn into_once(self) -> BoxTransformerOnce<T, R>where
T: 'static,
R: 'static,
fn into_once(self) -> BoxTransformerOnce<T, R>where
T: 'static,
R: 'static,
BoxTransformerOnce. Read moreSource§fn to_box(&self) -> BoxTransformer<T, R>where
T: 'static,
R: 'static,
fn to_box(&self) -> BoxTransformer<T, R>where
T: 'static,
R: 'static,
Source§fn to_rc(&self) -> RcTransformer<T, R>where
T: 'static,
R: 'static,
fn to_rc(&self) -> RcTransformer<T, R>where
T: 'static,
R: 'static,
Source§fn to_arc(&self) -> ArcTransformer<T, R>where
T: 'static,
R: 'static,
fn to_arc(&self) -> ArcTransformer<T, R>where
T: 'static,
R: 'static,
Source§fn to_fn(&self) -> impl Fn(T) -> R
fn to_fn(&self) -> impl Fn(T) -> R
Source§fn to_once(&self) -> BoxTransformerOnce<T, R>where
T: 'static,
R: 'static,
fn to_once(&self) -> BoxTransformerOnce<T, R>where
T: 'static,
R: 'static,
BoxTransformerOnce without consuming self Read more