Trait nix_compat::nar::wire::tag::Tag

source ·
pub trait Tag: Sized {
    type Buf: AsMut<[u8]> + Send;

    const OFF: usize;
    const MIN: usize;

    // Required methods
    fn make_buf() -> Self::Buf;
    fn from_u8(x: u8) -> Option<Self>;
    fn as_bytes(&self) -> &'static [u8] ;
}
Expand description

A type implementing Tag represents a static hash set of byte strings, with a very simple perfect hash function: every element has a unique discriminant at a common byte offset. The values of the type represent the members by this single discriminant byte; they are indices into the hash set.

Required Associated Types§

source

type Buf: AsMut<[u8]> + Send

Minimal suitably sized buffer for reading the wire representation

HACK: This is a workaround for const generics limitations.

Required Associated Constants§

source

const OFF: usize

Discriminant offset

source

const MIN: usize

Minimum variant length

Required Methods§

source

fn make_buf() -> Self::Buf

Make an instance of Self::Buf

source

fn from_u8(x: u8) -> Option<Self>

Convert a discriminant into the corresponding variant

source

fn as_bytes(&self) -> &'static [u8]

Convert a variant back into the wire representation

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Tag for Entry

source§

const OFF: usize = 0usize

source§

const MIN: usize = 16usize

source§

type Buf = [u8; 32]

source§

impl Tag for Node

source§

const OFF: usize = 16usize

source§

const MIN: usize = 24usize

source§

type Buf = [u8; 40]