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
use ;
use Hash;
use crateErrorId;
/// Marker for a type usable as a stream / aggregate id.
///
/// An id is anything that can be cloned, moved across threads, compared,
/// hashed, printed, and — crucially — viewed as bytes for use as a storage
/// key (`AsRef<[u8]>` is the stable byte representation; `Display` is for
/// humans, never for serialization).
///
/// There is nothing to implement: a [blanket impl](#impl-Id-for-T) covers
/// every type that already satisfies the supertraits, so a plain newtype
///
/// ```
/// # use std::fmt;
/// #[derive(Debug, Clone, Hash, PartialEq, Eq)]
/// struct AccountId(String);
/// impl fmt::Display for AccountId {
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(&self.0) }
/// }
/// impl AsRef<[u8]> for AccountId {
/// fn as_ref(&self) -> &[u8] { self.0.as_bytes() }
/// }
/// ```
///
/// *is* an `Id` — no `impl Id` block, no associated const.
/// Every type carrying the supertraits is an [`Id`] — declaring an id is a
/// newtype plus `Display`/`AsRef<[u8]>`, with no hand-written `Id` impl.