Skip to main content

schema_for

Function schema_for 

Source
pub fn schema_for(file_type: [u8; 4]) -> Option<&'static [&'static [Field]]>
Expand description

The schema of the view modelling a container, found by its magic. The schema of the view modelling file_type, in parts, or None.

A caller holding a parsed GFF and no idea what it is cannot name a view, and every schema entry point is generic over one: T::parts(), routes_in::<T>() and FieldRoute::field_in::<T>() all resolve at compile time. A raw tree over a file the user picked at runtime is the caller that cannot supply the T.

None means this crate models nothing for that container, which is the answer for a format it does not cover and for the untyped GENERIC_FILE_TYPE. The generic container is not a gap: every reader here accepts it alongside its own magic, so such a file could be any of them and naming one would be a guess. A caller wanting a schema for one has to be told which view by something other than the bytes.

Parts rather than one slice, because that is how a schema holds a type that flattens a shared block, and it is what FieldRoute::field_under takes.