1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use crateDomainError;
/// Generic, domain-level mapper trait.
///
/// `T` is the **output** type this mapper produces, declared at the `impl` site so that
/// `impl Mapper<Medication> for CreateMedicationMapper` is self-documenting.
/// `Source` is the associated type that defines what the mapper consumes.
///
/// Lives in the domain layer — no I/O, no external dependencies.
/// Concrete implementations belong in the application or infrastructure layers.
///
/// The trait is `Send + Sync` so it can be stored behind `Arc<dyn Mapper<T>>`.
///
/// # Examples
///
/// ```rust
/// use bitpill::domain::ports::mapper::Mapper;
/// use bitpill::domain::errors::DomainError;
///
/// struct UpperMapper;
///
/// impl Mapper<String> for UpperMapper {
/// type Source = String;
/// fn map(&self, src: String) -> Result<String, DomainError> {
/// Ok(src.to_uppercase())
/// }
/// }
/// ```