Skip to main content

encoder_newtype_exact

Macro encoder_newtype_exact 

Source
macro_rules! encoder_newtype_exact {
    (
        $(#[$($struct_attr:tt)*])*
        $vis:vis struct $name:ident<$lt:lifetime>($encoder:ty);
    ) => { ... };
}
Expand description

Implements a newtype around an exact-size encoder.

The new type will implement both the Encoder and ExactSizeEncoder traits by forwarding to the wrapped encoder.

ยงExamples

use bitcoin_consensus_encoding::{encoder_newtype_exact, ArrayEncoder};

encoder_newtype_exact! {
    /// The encoder for the [`Bar`] type.
    pub struct BarEncoder<'e>(ArrayEncoder<32>);
}

For a full example see ./examples/encoder.rs.