Skip to main content

extract_from_reader

Function extract_from_reader 

Source
pub async fn extract_from_reader<R: AsyncRead + Unpin>(
    reader: R,
) -> Result<(MetadataMap, Keywords, MetaTagGroups), MetadataError>
Available on crate feature tokio only.
Expand description

Reads everything from reader and runs crate::extract_and_prepare_metadata.

§Errors

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

§Example

use metadata_gen::tokio::extract_from_reader;

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