pub fn write_len_bits<W: Write>(w: &mut Writer<W>, len: usize) -> io::Result<()> {
    // In debug mode crash on large lengths
    debug_assert!(len <= 0xFFFF);

    let (ty, size) = match len {
        0 ... 31 => (0, 5),
        32 ... 255 => (1, 8),
        256 ... 1023 => (2, 10),
        1024 ... 65_536 => (3, 16),
        _ => return Err(io::Error::new(io::ErrorKind::InvalidInput, "String too long")),
    };

    w.write_unsigned(ty, 2)?;
    w.write_unsigned(len as u64, size)?;
    Ok(())
}
/// Helper to write a dynamic length prefix
Helper to write a dynamic length prefix
Helper to write a dynamic length prefix
pub fn write_len_bits<W: Write>(w: &mut Writer<W>, len: usize) -> io::Result<()> {
    // In debug mode crash on large lengths
    debug_assert!(len <= 0xFFFF);
    let (ty, size) = match len {
        0 ... 31 => (0, 5),
        32 ... 255 => (1, 8),
        256 ... 1023 => (2, 10),
        1024 ... 65_536 => (3, 16),
        _ => return Err(io::Error::new(io::ErrorKind::InvalidInput, "String too long")),
    };
    w.write_unsigned(ty, 2)?;
    w.write_unsigned(len as u64, size)?;
    Ok(())
}
pub fn write_len_bits < W : Write > ( w : & mut Writer < W > , len : usize ) -> io :: Result < ( ) > { // In debug mode crash on large lengths debug_assert ! ( len 0xFFFF ) ; let ( ty , size ) = match len { 0 ... 31 => ( 0 , 5 ) , 32 ... 255 => ( 1 , 8 ) , 256 ... 1023 => ( 2 , 10 ) , 1024 ... 65_536 => ( 3 , 16 ) , _ => return Err ( io :: Error :: new ( io :: ErrorKind :: InvalidInput , " " ) ) , } ; w . write_unsigned ( ty , 2 ) ? ; w . write_unsigned ( len as u64 , size ) ? ; Ok ( ( ) ) }
Helper to write a dynamic length prefix
Helper to write a dynamic length prefix
w
&mut Writer<W>
len
usize