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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//! Provides types and traits for structuring enveloped data with metadata.
//!
//! The `envelope` module defines abstractions for working with data that includes
//! additional metadata, such as correlation identifiers and timestamps. This can
//! be useful for event-driven systems, logging, and message passing.
//!
//! ## Features
//!
//! This module is enabled via the `"envelope"` feature in `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! tagid = { version = "0.2", features = ["envelope"] }
//! ```
//!
//! ## Overview
//!
//! - [`Envelope`](Envelope): A wrapper that encapsulates an entity with metadata.
//! - [`IntoEnvelope`](IntoEnvelope): A trait for converting entities into envelopes.
//! - [`MetaData`](MetaData): Stores additional metadata associated with an entity.
//! - [`Correlation`](Correlation): Defines a correlation ID for tracking related entities.
//! - [`ReceivedAt`](ReceivedAt): Ensures an entity has a timestamp indicating when it was received.
pub use ;
pub use ;
use crateId;
use Timestamp;
/// Defines a correlation identifier for tracking related entities.
///
/// This trait is typically implemented by messages or events that belong
/// to a larger workflow or transaction.
///
/// # Example
///
/// ```rust
/// use tagid::{Id, envelope::Correlation};
///
/// struct Event {
/// correlation_id: Id<Event, String>,
/// }
///
/// impl Correlation for Event {
/// type Correlated = Event;
/// type IdType = String;
///
/// fn correlation(&self) -> &Id<Self::Correlated, Self::IdType> {
/// &self.correlation_id
/// }
/// }
/// ```
/// Provides a timestamp indicating when an entity was received.
///
/// This trait is useful in event-driven systems where it is important
/// to track when data was received.
///
/// # Example
///
/// ```rust, ignore
/// use tagid::envelope::ReceivedAt;
/// use iso8601_timestamp::Timestamp;
///
/// struct Message {
/// timestamp: Timestamp,
/// }
///
/// impl ReceivedAt for Message {
/// fn recv_timestamp(&self) -> Timestamp {
/// self.timestamp
/// }
/// }
/// ```