Skip to main content

Module flac

Module flac 

Source

Structs§

FlacMeta
The metadata region of a FLAC file: where audio begins and the structural blocks to carry over. Unlike FlacScan, this does not include audio_length (which requires the full file size), so it can be computed from the front alone.
FlacScan
Result of scanning a FLAC file: where audio begins/ends and the structural blocks to preserve.
MetadataBlock
A preserved FLAC metadata block: its type and its body (excluding the 4-byte header).

Constants§

MAX_BLOCK_BODY
Inclusive maximum body length of a FLAC metadata block (24-bit length field).

Functions§

locate_audio
Parse the FLAC metadata section of a complete file, returning the audio boundary, audio length, and the structural blocks to carry over.
read_metadata
Parse just the FLAC metadata region (the front of the file), recovering the audio boundary and structural blocks. Use when the audio length is already known (e.g. stored in a database) and the full file should not be read.
read_metadata_bounded
Bounded twin of read_metadata: walk the metadata blocks present in prefix (which may be a front-only window of the file). If a block’s declared body runs past the prefix, return NeedMore { up_to } with the exact end of that block — the caller widens the window and retries. Otherwise Complete.
read_pictures
Extract all PICTURE blocks from a complete FLAC file as embedded pictures, for scan-time art ingestion. Returns an empty vec if there are none.
read_vorbis_comments
Read the existing VORBIS_COMMENT block from a complete FLAC file, returning (FIELD, value) pairs in order. Comments without a = are skipped. Returns an empty vec if there is no comment block. Used by the scanner to seed tags.
split_preserved
Split a FLAC file’s preserved metadata blocks into the read-only structural store (STREAMINFO/SEEKTABLE, as (kind, body) pairs in file order) and the editable binary tags (APPLICATION/CUESHEET, as EmbeddedBinaryTags keyed by block name; payload is the full block body, including APPLICATION’s 4-byte app id). Blocks of any other type are ignored (PICTURE/VORBIS_COMMENT are handled by their own paths and are never in preserved).
structural_block_type
Map a stored structural-block kind string back to its FLAC block type. Only STREAMINFO/SEEKTABLE live in the structural store; everything else returns None (APPLICATION/CUESHEET are binary tags, not structural).
synthesize_layout
Build the ordered segment layout for a synthesized FLAC file: fLaC + structural blocks (sorted by type) + a regenerated VORBIS_COMMENT + streamed APPLICATION/CUESHEET binary tags + PICTURE blocks (one ArtImage segment each) + the backing audio. Structural blocks must be only STREAMINFO/SEEKTABLE; APPLICATION/CUESHEET ride through binary_tags.