revelo_reader/lib.rs
1//! Input/reader registration layer for the
2//! [revelo](https://github.com/vbasky/revelo) media-metadata library.
3//!
4//! `revelo-reader` is responsible for populating the `Reader` field on the
5//! `General` stream of a [`revelo_core::FileAnalyze`] analysis context. The
6//! `Reader` field records the source type through which a file (or URL) was
7//! opened, mirroring the reader-registration step that MediaInfoLib performs
8//! before dispatching to format parsers.
9//!
10//! # Public functions
11//!
12//! | Function | `Reader` value set |
13//! | --- | --- |
14//! | [`parse_file_reader`] | `"File"` — ordinary filesystem path |
15//! | [`parse_directory_reader`] | `"Directory"` — directory source |
16//! | [`parse_http_reader`] | `"HTTP"` — HTTP/HTTPS URL |
17//! | [`parse_mms_reader`] | `"MMS"` — Microsoft Media Server URL |
18//!
19//! Each function accepts a mutable reference to a `FileAnalyze` context,
20//! prepares the `General` stream if it does not already exist, writes the
21//! appropriate `Reader` value, and returns `true`.
22//!
23//! # Example
24//!
25//! ```no_run
26//! use revelo_core::FileAnalyze;
27//! use revelo_reader::parse_file_reader;
28//!
29//! let mut fa = FileAnalyze::new(&[]);
30//! parse_file_reader(&mut fa);
31//! // The General stream now has Reader = "File".
32//! ```
33
34#![deny(unsafe_code)]
35
36use revelo_core::{FileAnalyze, StreamKind};
37
38pub fn parse_file_reader(fa: &mut FileAnalyze) -> bool {
39 let pos = fa.stream_prepare(StreamKind::General);
40 fa.set_field(StreamKind::General, pos, "Reader", "File");
41 true
42}
43
44pub fn parse_directory_reader(fa: &mut FileAnalyze) -> bool {
45 let pos = fa.stream_prepare(StreamKind::General);
46 fa.set_field(StreamKind::General, pos, "Reader", "Directory");
47 true
48}
49
50pub fn parse_http_reader(fa: &mut FileAnalyze) -> bool {
51 let pos = fa.stream_prepare(StreamKind::General);
52 fa.set_field(StreamKind::General, pos, "Reader", "HTTP");
53 true
54}
55
56pub fn parse_mms_reader(fa: &mut FileAnalyze) -> bool {
57 let pos = fa.stream_prepare(StreamKind::General);
58 fa.set_field(StreamKind::General, pos, "Reader", "MMS");
59 true
60}