pub fn parse_file_with_annotation<T: Descriptor>(
content: &[u8],
) -> Result<(Option<TypeAnnotation>, T), Error>Expand description
Parses a descriptor from file content, returning the type annotation.
Like parse_file, but also returns the @type annotation if one
was present at the beginning of the content.
§Type Parameters
T- The descriptor type to parse (must implementDescriptor)
§Arguments
content- The raw file content (possibly compressed)
§Returns
A tuple of:
Option<TypeAnnotation>- The type annotation if presentT- The parsed descriptor
§Errors
Returns Error::Parse if decompression or parsing fails.
§Example
use stem_rs::descriptor::{parse_file_with_annotation, ServerDescriptor};
let content = std::fs::read("server-descriptor").unwrap();
let (annotation, descriptor): (_, ServerDescriptor) =
parse_file_with_annotation(&content).unwrap();
if let Some(ann) = annotation {
println!("Type: {} v{}.{}", ann.name, ann.major_version, ann.minor_version);
}