euv-docs 0.48.2

Cross-platform documentation viewer and static site generator powered by euv and euv-ui.
Documentation
use super::*;

/// Per-page heavy content record stored inside the compressed `site_bodies.euvz` payload.
#[derive(Clone, Data, Debug, Default, Deserialize, New, PartialEq, Serialize)]
pub struct PackedPageBody {
    /// Raw Markdown body text used by the native `EuvMarkdown` renderer.
    #[serde(default, skip_serializing_if = "String::is_empty")]
    pub(crate) markdown_body: String,
    /// Structured fallback blocks retained only when `markdown_body` is empty.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub(crate) blocks: Vec<DocBlock>,
}

/// Split site bundle pairing a lightweight plaintext metadata shell with compressed page bodies.
#[derive(Clone, Debug, Eq, Getter, New, PartialEq)]
pub struct PackedSiteBundle {
    /// Compact plaintext JSON carrying site metadata, TOC headings, and page index records.
    pub(crate) shell_json: String,
    /// `EUVZ`-compressed UTF-8 JSON payload storing all page bodies for the locale.
    pub(crate) compressed_bodies: Vec<u8>,
}

/// LSB-first bit writer accumulating variable-width canonical Huffman codes into a byte vector.
#[derive(Clone, Data, Debug, Default)]
pub(crate) struct CodecBitWriter {
    /// Output byte stream.
    #[get(pub(crate))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) bytes: Vec<u8>,
    /// Buffered unwritten bits stored in the lowest `bit_count` positions.
    #[get(pub(crate), type(copy))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) bit_buf: u64,
    /// Number of valid bits currently held in `bit_buf`.
    #[get(pub(crate), type(copy))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) bit_count: u32,
}

/// LSB-first bit reader streaming variable-width canonical Huffman codes from an immutable slice.
#[derive(Clone, Data, Debug)]
pub(crate) struct CodecBitReader<'a> {
    /// Source byte slice.
    #[get(pub(crate), type(copy))]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) data: &'a [u8],
    /// Current byte read cursor within `data`.
    #[get(pub(crate), type(copy))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) cursor: usize,
    /// Prefetched bits stored in the lowest `bit_count` positions.
    #[get(pub(crate), type(copy))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) bit_buf: u64,
    /// Number of valid unread bits currently held in `bit_buf`.
    #[get(pub(crate), type(copy))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) bit_count: u32,
}