packable 0.11.0

A crate for packing and unpacking binary representations.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use crate::packer::Packer;

#[repr(transparent)]
pub(crate) struct LenPacker(pub(crate) usize);

impl Packer for LenPacker {
    type Error = core::convert::Infallible;

    #[inline]
    fn pack_bytes<B: AsRef<[u8]>>(&mut self, bytes: B) -> Result<(), Self::Error> {
        self.0 += bytes.as_ref().len();

        Ok(())
    }
}