sark-http 0.39.0

HTTP wire types, semantics, codecs, and ownership invariants for Sark
Documentation
use std::{mem::MaybeUninit, num::NonZero};

pub mod raw;

pub(crate) const fn decimal_length(length: usize) -> ([u8; 20], usize) {
    let mut digits = [0; 20];
    let len = raw::decimal(length, &mut digits).len();
    (digits, digits.len() - len)
}

pub trait Wire {
    fn decimal_len(self) -> NonZero<usize>;

    /// Encodes once backwards, borrowing only the initialized decimal suffix.
    fn decimal(self, buf: &mut [u8; 20]) -> &[u8];

    /// Initializes and borrows only the decimal suffix.
    fn decimal_uninit(self, buf: &mut [MaybeUninit<u8>; 20]) -> &[u8];
}

const _: () = assert!(usize::BITS <= u64::BITS);