Skip to main content

AllowedLenBitString

Trait AllowedLenBitString 

Source
pub trait AllowedLenBitString {
    const ALLOWED_LEN_RANGE: RangeInclusive<u16>;

    // Provided method
    fn check_bit_len(bit_len: u16) -> Result<(), Error> { ... }
}
Expand description

Trait automatically derived on structs, by the BitString macro. Used for checking if binary data fits into defined struct.

/// Bit length of 2
struct MyBitString {
    flag1: bool,
    flag2: bool,
}
use der::BitString;

/// Bit length of 3..=4
#[derive(BitString)]
struct MyBitString {
    flag1: bool,
    flag2: bool,
    flag3: bool,

    #[asn1(optional = "true")]
    flag4: bool,
}

Required Associated Constants§

Source

const ALLOWED_LEN_RANGE: RangeInclusive<u16>

Implementer must specify how many bits are allowed

Provided Methods§

Source

fn check_bit_len(bit_len: u16) -> Result<(), Error>

Check the bit length.

§Errors

Returns an error if the bitstring is not in expected length range.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§