euv-core 0.52.0

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
use super::*;

/// Parsed `.blend` header metadata supporting both classic 12-byte (2.x-4.x) and Blender 5.0+ 17-byte large headers.
#[derive(Clone, Copy, Data, Debug, Eq, PartialEq)]
pub struct BlendHeader {
    /// Major Blender version (e.g., `4` or `5`).
    #[get(type(copy))]
    pub(crate) version_major: u16,
    /// Minor Blender version (e.g., `2` for `4.2`, `1` for `5.1`).
    #[get(type(copy))]
    pub(crate) version_minor: u16,
    /// Pointer width in bytes (`4` for 32-bit, `8` for 64-bit).
    #[get(type(copy))]
    pub(crate) pointer_size_bytes: u8,
    /// `true` for little-endian (`'v'`), `false` for big-endian (`'V'`).
    #[get(type(copy))]
    pub(crate) is_little_endian: bool,
    /// `true` when using Blender 5.0+ extended large header & 32-byte `LargeBHead8`.
    #[get(type(copy))]
    pub(crate) is_large_header_v5: bool,
    /// Byte length of the header before the first `BHead` block (`12` or `17`).
    #[get(type(copy))]
    pub(crate) header_size_bytes: usize,
    /// File-format revision (`0` for classic 2.x-4.x, `>= 1` for Blender 5.0+).
    #[get(type(copy))]
    pub(crate) format_version: u16,
}

/// Summary of one `BHead` data block scanned inside a `.blend` file.
#[derive(Clone, Data, Debug, Eq, PartialEq)]
pub struct BlendBlockSummary {
    /// Four-byte ASCII block code trimmed of trailing NULs (e.g., `"OB"`, `"ME"`, `"DNA1"`).
    pub(crate) code: String,
    /// Classified Blender ID block kind.
    #[get(type(copy))]
    pub(crate) kind: BlendBlockKind,
    /// Payload length in bytes following the block header.
    #[get(type(copy))]
    pub(crate) byte_length: u64,
    /// SDNA struct index (`sdna_nr`).
    #[get(type(copy))]
    pub(crate) sdna_index: u32,
    /// Array element count (`nr`).
    #[get(type(copy))]
    pub(crate) element_count: u64,
}

/// Parsed metadata from the `DNA1` SDNA schema table inside a `.blend` file.
#[derive(Clone, Data, Debug, Default, Eq, PartialEq)]
pub struct BlendDnaSchemaSummary {
    /// Total field name entries in `NAME`.
    #[get(type(copy))]
    pub(crate) name_count: usize,
    /// Total C type entries in `TYPE`/`TLEN`.
    #[get(type(copy))]
    pub(crate) type_count: usize,
    /// Total struct definitions in `STRC`.
    #[get(type(copy))]
    pub(crate) struct_count: usize,
    /// Resolved byte offset of `ID.name` inside Blender `ID` blocks, if present in SDNA.
    #[get(type(copy))]
    pub(crate) id_name_offset: Option<usize>,
    /// Resolved byte buffer length of `ID.name` (typically `66` in 4.x or `258` in 5.x).
    #[get(type(copy))]
    pub(crate) id_name_max_len: Option<usize>,
}

/// Complete inspection report extracted from a `.blend` file with zero external Blender process required.
#[derive(Clone, Data, Debug, Default, Eq, PartialEq)]
pub struct BlendInspectionReport {
    /// Major Blender version number (e.g., `4` or `5`).
    #[get(type(copy))]
    pub(crate) blender_version_major: u16,
    /// Minor Blender version number (e.g., `2` for `4.2`, `1` for `5.1`).
    #[get(type(copy))]
    pub(crate) blender_version_minor: u16,
    /// Formatted Blender version string (e.g., `"4.2"` or `"5.1"`).
    pub(crate) version_string: String,
    /// Pointer width in bytes (`4` or `8`).
    #[get(type(copy))]
    pub(crate) pointer_size_bytes: u8,
    /// `true` when encoded in little-endian byte order.
    #[get(type(copy))]
    pub(crate) is_little_endian: bool,
    /// `true` when the file uses the Blender 5.0+ extended large header format.
    #[get(type(copy))]
    pub(crate) is_large_header_v5: bool,
    /// Detected container compression (`None`, `Gzip`, or `Zstd`).
    #[get(type(copy))]
    pub(crate) compression: BlendCompression,
    /// Total number of `BHead` blocks scanned.
    #[get(type(copy))]
    pub(crate) block_count: usize,
    /// Number of SDNA struct definitions parsed from `DNA1`.
    #[get(type(copy))]
    pub(crate) dna_struct_count: usize,
    /// Number of SDNA type entries parsed from `DNA1`.
    #[get(type(copy))]
    pub(crate) dna_type_count: usize,
    /// Number of SDNA field name entries parsed from `DNA1`.
    #[get(type(copy))]
    pub(crate) dna_name_count: usize,
    /// Discovered Blender Scene names (`SC`).
    pub(crate) scenes: Vec<String>,
    /// Discovered Blender Collection names (`GR`).
    pub(crate) collections: Vec<String>,
    /// Discovered Blender Object names (`OB`).
    pub(crate) objects: Vec<String>,
    /// Discovered Blender Mesh names (`ME`).
    pub(crate) meshes: Vec<String>,
    /// Discovered Blender Material names (`MA`).
    pub(crate) materials: Vec<String>,
    /// Discovered Blender Camera names (`CA`).
    pub(crate) cameras: Vec<String>,
    /// Discovered Blender Light names (`LA`).
    pub(crate) lights: Vec<String>,
    /// Discovered Blender Armature names (`AR`).
    pub(crate) armatures: Vec<String>,
    /// Discovered Blender Animation Action names (`AC`).
    pub(crate) actions: Vec<String>,
    /// Discovered Blender Image names (`IM`).
    pub(crate) images: Vec<String>,
    /// Discovered Blender NodeTree names (`NT`).
    pub(crate) node_trees: Vec<String>,
    /// Non-fatal structural warnings encountered during inspection.
    pub(crate) warnings: Vec<String>,
}

/// Stateless pure-Rust `.blend` 4.x/5.x binary header, block, and SDNA inspector.
#[derive(Clone, Copy, Debug, Default)]
pub struct BlendInspector;