Skip to main content

extract_from_reader

Function extract_from_reader 

Source
pub fn extract_from_reader<R: Read>(
    reader: R,
) -> Result<(MetadataMap, Keywords, MetaTagGroups), MetadataError>
Available on crate feature std only.
Expand description

Reads everything from reader and runs extract_and_prepare_metadata.

An empty (or whitespace-only) input yields empty metadata rather than an error, matching metadata_gen::tokio::extract_from_file (feature tokio).

§Errors

MetadataError::IoError when the read fails, otherwise whatever extract_and_prepare_metadata returns.

§Example

use metadata_gen::io::extract_from_reader;

let doc = b"---\ntitle: Reader\n---\nbody" as &[u8];
let (metadata, _, _) = extract_from_reader(doc).unwrap();
assert_eq!(metadata["title"], "Reader");