@@ -7,8 +7,43 @@ use crate::{types::enr::Enr, OverlayContentKey};
7
7
use super :: query_trace:: QueryTrace ;
8
8
9
9
/// The SSZ encoded representation of content key.
10
+ ///
11
+ /// This is an alias for [alloy::primitives::Bytes] type, which is a wrapper around [bytes::Bytes].
12
+ ///
13
+ /// While `Vec<u8>` is the most common way to represent the byte array, its usage as raw content
14
+ /// key is discouraged in favor of this type, for following reasons:
15
+ ///
16
+ /// - The [bytes::Bytes] is cheaply cloneable and sliceable chunk of contiguous memory
17
+ /// - This makes it more suitable when cloning/coping is frequent, and modification is not
18
+ /// - The [alloy::primitives::Bytes] is a wrapper around `bytes::Bytes` that implements frequently
19
+ /// used traits (e.g. [ssz::Encode], [ssz::Decode], [std::fmt::Display], [std::str::FromStr]) and
20
+ /// supports (de)serialization to/from hex strings (with or without "0x" prefix).
21
+ ///
22
+ /// Lack of support in third-party libraries is the most common issue with using this type. To work
23
+ /// around it, one can do any of the following:
24
+ ///
25
+ /// - Wrap `RawContentKey` in a new type, and implement thirt-party trait that adds support
26
+ /// - Use `RawContentKey::to_vec` and `RawContentKey::from` to convert to/from `Vec<u8>`
10
27
pub type RawContentKey = Bytes ;
28
+
11
29
/// The SSZ encoded representation of content value.
30
+ ///
31
+ /// This is an alias for [alloy::primitives::Bytes] type, which is a wrapper around [bytes::Bytes].
32
+ ///
33
+ /// While `Vec<u8>` is the most common way to represent the byte array, its usage as raw content
34
+ /// value is discouraged in favor of this type, for following reasons:
35
+ ///
36
+ /// - The [bytes::Bytes] is cheaply cloneable and sliceable chunk of contiguous memory
37
+ /// - This makes it more suitable when cloning/coping is frequent, and modification is not
38
+ /// - The [alloy::primitives::Bytes] is a wrapper around `bytes::Bytes` that implements frequently
39
+ /// used traits (e.g. [ssz::Encode], [ssz::Decode], [std::fmt::Display], [std::str::FromStr]) and
40
+ /// supports (de)serialization to/from hex strings (with or without "0x" prefix).
41
+ ///
42
+ /// Lack of support in third-party libraries is the most common issue with using this type. To work
43
+ /// around it, one can do any of the following:
44
+ ///
45
+ /// - Wrap `RawContentValue` in a new type, and implement thirt-party trait that adds support
46
+ /// - Use `RawContentValue::to_vec` and `RawContentValue::from` to convert to/from `Vec<u8>`
12
47
pub type RawContentValue = Bytes ;
13
48
14
49
pub type DataRadius = U256 ;
0 commit comments