buf_sized 0.1.1

Calculate buffer sizes needed by types
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! A library for types with a fixed buffer size.
mod impls;

#[cfg(feature = "derive")]
pub use buf_sized_derive::BufSized;

/// A trait for types that have a fixed buffer size.
pub trait BufSized {
    /// The buffer size of the type.
    const BUF_SIZE: usize;
}

/// Get the buffer size of a type.
#[must_use]
pub const fn buf_size<T: BufSized>() -> usize {
    T::BUF_SIZE
}