rsmediainfo 0.2.0

Rust wrapper for MediaInfo library
//! # rsmediainfo
//!
//! A Rust library for extracting media file metadata through the MediaInfo
//! shared library.
//!
//! ## Overview
//!
//! Provides a safe Rust interface on top of the MediaInfo C library so
//! callers can extract detailed metadata from audio, video, and other media
//! files without writing FFI code themselves. The crate covers the full
//! surface most callers need:
//!
//! - file, reader, and URL inputs through a single [`MediaInfo::parse`]
//!   entrypoint plus a family of specialized helpers
//! - structured track models with typed and dynamic attribute access
//! - raw text, JSON, XML, and `%`-delimited template output formats
//! - configurable parsing through [`ParseOptions`]
//! - reusable [`MediaInfoContext`] for batch workloads that parse many
//!   files in a row without repeating the shared library load cost
//! - a typed error model ([`MediaInfoError`]) that surfaces every failure
//!   mode of the underlying library through [`Result`]
//! - cross-platform support (Windows, macOS, Linux) for both x86_64 and
//!   arm64 where the underlying library publishes a build
//!
//! ## Library availability
//!
//! The MediaInfo shared library must be available at runtime. By default
//! the `bundled` feature is enabled, which downloads a copy of the library
//! for the target platform during the build and ships it alongside the
//! resulting binary. To use a system-installed copy instead, disable
//! default features:
//!
//! ```bash
//! cargo build --no-default-features
//! ```
//!
//! When the bundled feature is enabled but downloads are not desirable
//! (offline builds, sandboxed CI), set `RS_MEDIAINFO_SKIP_DOWNLOAD=1`. The
//! download timeout can be tuned with `RS_MEDIAINFO_DOWNLOAD_TIMEOUT`.
//!
//! ## Quickstart
//!
//! ```no_run
//! use rsmediainfo::MediaInfo;
//!
//! // Parse a file from disk and walk its tracks.
//! let mi = MediaInfo::parse_media_info("video.mp4").unwrap();
//! for track in mi.tracks() {
//!     println!("{} track", track.track_type());
//! }
//! ```
//!
//! Runnable end-to-end examples for the most common workflows live under
//! the crate's `examples/` directory:
//!
//! - `parse_path` — parse a media file from a path on disk
//! - `parse_reader` — parse from an already-open `File` via `BufReader`
//! - `parse_url` — fetch a remote file and parse it through an in-memory
//!   cursor
//! - `parse_raw_output` — request raw JSON output instead of a structured
//!   value
//! - `parse_xml` — construct a [`MediaInfo`] directly from a pre-generated
//!   XML string with no shared library required at runtime
//! - `batch_parse` — build a [`MediaInfoContext`] once and parse a list of
//!   files through it without reloading the shared library
//!
//! Run any of them with `cargo run --example <name>`.
//!
//! ## Thread safety
//!
//! The underlying media library shares option state across every handle in
//! the process, so this crate serializes parse calls behind an internal
//! mutex to keep results deterministic. Pure XML parsing through
//! [`MediaInfo::from_xml`] is fully concurrent and never takes the lock.
//! See the README's "Thread safety" section for the full story.

mod error;
mod ffi;
pub mod mediainfo;
mod platform;
mod track;
mod xml;

pub use error::{EncodingErrorMode, MediaInfoError, Result};
pub use mediainfo::{
    MediaInfo, MediaInfoContext, MediaInfoInput, MediaInfoSource, ParseOptions, ParseOutput,
    ReadSeek,
};
pub use track::{AttributeValue, Track, TrackId};

/// Crate version, taken from `CARGO_PKG_VERSION` at compile time.
pub const VERSION: &str = env!("CARGO_PKG_VERSION");