pub struct CompactSizeU64Decoder { /* private fields */ }Expand description
Decodes a compact size encoded integer as a raw u64.
If you are decoding a length prefix, you probably want CompactSizeDecoder instead.
This decoder performs no limit check and no conversion to usize. It exists for the small
number of Bitcoin protocol fields that are compact-size-encoded integers but are not length
prefixes (e.g. service flags in the version message). For those fields the full u64 range is
meaningful and there is no associated allocation whose size would be controlled by the decoded
value.
§Denial-of-service warning
Do not use this decoder for length prefixes. If the decoded value is used to size an allocation,
for example as the length of a Vec, a malicious peer can send a compact size value of up to
2^64-1 and cause an out-of-memory condition. CompactSizeDecoder prevents this by enforcing a
configurable upper bound before returning the value.
For more information about decoders see the documentation of the Decoder trait.
Implementations§
Source§impl CompactSizeU64Decoder
impl CompactSizeU64Decoder
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Constructs a new CompactSizeU64Decoder.
See the struct-level documentation for guidance on when to use this decoder versus
CompactSizeDecoder.
Trait Implementations§
Source§impl Clone for CompactSizeU64Decoder
impl Clone for CompactSizeU64Decoder
Source§fn clone(&self) -> CompactSizeU64Decoder
fn clone(&self) -> CompactSizeU64Decoder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more