Function emboss::extract_metadata [−][src]
pub fn extract_metadata(
buf: &[u8]
) -> Result<HashMap<Cow<'_, str>, Cow<'_, str>>, EmbossError>
Expand description
Extract embossed metadata from the raw bytes in a section
The metadata is expected to be written in the following format:
Where
Please note that as this format assumes identifiers ending with ‘=’, identifiers may not contain an equal sign
Example usage:
// Example pulled directly from an example binary let data = "VERGEN_RUSTC_CHANNEL=stable\0VERGEN_RUSTC_COMMIT_DATE=2021-05-09\0"; let metadata = emboss::extract_metadata(data.as_bytes()).unwrap(); let value = metadata.get("VERGEN_RUSTC_CHANNEL").unwrap(); assert_eq!(value, "stable"); let value = metadata.get("VERGEN_RUSTC_COMMIT_DATE").unwrap(); assert_eq!(value, "2021-05-09");