Skip to main content

BitAmount

Trait BitAmount 

Source
pub trait BitAmount: Copy {
    // Required methods
    fn bits(self) -> u32;
    fn bytes(self) -> u32;
}
Expand description

A typed bit/byte amount for positioning directives — 4.bits(), 3.bytes() — resolving to a bit count. Bring it in with use bnb::prelude::*.

§Examples

use bnb::prelude::*;
assert_eq!(4u32.bits(), 4);
assert_eq!(3u32.bytes(), 24);

Used by the positioning directives, e.g. #[br(pad_before = 2u32.bytes())] — see guide::directives.

Required Methods§

Source

fn bits(self) -> u32

This many bits.

Source

fn bytes(self) -> u32

This many bytes (× 8 bits).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl BitAmount for i32

Source§

fn bits(self) -> u32

Source§

fn bytes(self) -> u32

Source§

impl BitAmount for u8

Source§

fn bits(self) -> u32

Source§

fn bytes(self) -> u32

Source§

impl BitAmount for u16

Source§

fn bits(self) -> u32

Source§

fn bytes(self) -> u32

Source§

impl BitAmount for u32

Source§

fn bits(self) -> u32

Source§

fn bytes(self) -> u32

Source§

impl BitAmount for u64

Source§

fn bits(self) -> u32

Source§

fn bytes(self) -> u32

Source§

impl BitAmount for usize

Source§

fn bits(self) -> u32

Source§

fn bytes(self) -> u32

Implementors§