Skip to main content

Crate revelo_core

Crate revelo_core 

Source
Expand description

Core parsing engine for revelo.

Transliterates MediaInfoLib’s File__Analyze infrastructure — the cursor-based byte reader every parser uses (Get_B*, Get_L*, Peek_*, Skip_*, bitstream mode) plus the element trace tree, typed stream collection, runtime config, and event dispatch — while also exposing ExifTool-style stream kinds (Exif, Iptc, Xmp, Icc, C2pa, MakerNotes) for camera-maker-note depth.

All read methods return native Rust types (u8u128, f32, f64) rather than out-parameters or C-style aliases. Truncated reads return 0 / empty slices and set a truncated() flag rather than panicking.

§Key public types

TypeRole
FileAnalyzeCursor over a &[u8] buffer; received by every parser
MediaFilePublic type alias for FileAnalyze
StreamCollectionAll parsed fields, keyed by (StreamKind, position)
StreamA single stream’s fields in insertion order plus an <extra> bucket
StreamKindDiscriminant: GeneralMenu (MediaInfo-compatible 0–6) + ExifMakerNotes (7–12)
ElementTree / ElementNodeStack-based trace tree (mirrors MediaInfoLib --trace output)
ReaderFluent Option-returning wrapper over FileAnalyze
MediaConfigDemux level, trace verbosity, parse speed, multi-file options

§Writing a parser

use revelo_core::{FileAnalyze, StreamKind};

fn my_parser(fa: &mut FileAnalyze) -> bool {
    // Non-advancing magic check
    if !fa.peek_magic(b"RIFF") {
        return false;
    }
    let _chunk_size = fa.get_b4("ChunkSize");
    let _form_tag   = fa.get_c4("FormTag");

    let pos = fa.stream_prepare(StreamKind::General);
    fa.set_field(StreamKind::General, pos, "Format", "MyFormat");
    true
}

Or via the higher-level Reader API (None signals truncation instead of falling back to 0):

use revelo_core::{FileAnalyze, Reader, StreamKind};

fn my_parser(fa: &mut FileAnalyze) -> bool {
    let mut r = Reader::wrap(fa);
    let Some(_size) = r.be_u32("Size") else { return false; };
    let pos = r.stream_prepare(StreamKind::Audio);
    r.set_field(StreamKind::Audio, pos, "BitDepth", "24");
    true
}

§#![deny(unsafe_code)]

The entire crate is enforced unsafe-free.

Re-exports§

pub use element::ElementInfo;
pub use element::ElementNode;
pub use element::ElementTree;
pub use file_analyze::FileAnalyze;
pub use file_level::FileLevelInfo;
pub use file_level::fill_file_level_fields;
pub use reader::Reader;
pub use stream::Stream;
pub use stream::StreamCollection;
pub use stream::StreamKind;

Modules§

channel_grouping
channel_splitting
computed_fields
config
data_helpers
element
Element trace tree — transliteration of MediaInfoLib’s Element[Element_Level] stack and element_details::Element_Node tree.
events
file_analyze
Big-endian readers first; little-endian / floats / strings to follow. Return-value style: each Get_B* consumes N bytes, returns the value, and advances the position. If the read would overrun, truncated() returns true and the returned value is zero.
file_level
File-level field derivation shared by every front-end (CLI, diff harness, future C ABI shim).
ibi
interlacement
mime
multi_file
prelude
Convenience re-exports of the most commonly used types.
reader
Ergonomic byte reader — wraps FileAnalyze with a fluent, Rust-native API.
reference
Container-level reference file tracker.
stream
Stream model — transliteration of MediaInfoLib’s per-stream Fill / Retrieve state.
timecode

Functions§

duration_ms
Round-to-nearest duration in milliseconds from sample count and sample rate.

Type Aliases§

MediaFile
Ergonomic alias for FileAnalyze. Both names refer to the same type.