redoubt_codec_core/
blankets.rs

1// Copyright (c) 2025-2026 Federico Hoerth <memparanoid@gmail.com>
2// SPDX-License-Identifier: GPL-3.0-only
3// See LICENSE in the repository root for full license text.
4
5//! Blanket implementations for common wrapper types.
6
7use alloc::boxed::Box;
8
9use crate::codec_buffer::RedoubtCodecBuffer;
10use crate::error::{DecodeError, EncodeError, OverflowError};
11use crate::traits::{BytesRequired, Decode, Encode};
12
13// ═══════════════════════════════════════════════════════════════════════════════
14// Box<T>
15// ═══════════════════════════════════════════════════════════════════════════════
16
17impl<T> BytesRequired for Box<T>
18where
19    T: BytesRequired,
20{
21    #[inline(always)]
22    fn encode_bytes_required(&self) -> Result<usize, OverflowError> {
23        (**self).encode_bytes_required()
24    }
25}
26
27impl<T> Encode for Box<T>
28where
29    T: Encode,
30{
31    #[inline(always)]
32    fn encode_into(&mut self, buf: &mut RedoubtCodecBuffer) -> Result<(), EncodeError> {
33        (**self).encode_into(buf)
34    }
35}
36
37impl<T> Decode for Box<T>
38where
39    T: Decode,
40{
41    #[inline(always)]
42    fn decode_from(&mut self, buf: &mut &mut [u8]) -> Result<(), DecodeError> {
43        (**self).decode_from(buf)
44    }
45}