pub enum InputSource {
Text(String),
AnchoredText {
text: String,
anchor: String,
},
Reader(Box<dyn Read + 'static>),
}Expand description
Owned input that can be fed into the YAML parser.
This is primarily used by the include resolver: it can return either fully-owned in-memory text, or a fully-owned streaming reader.
Variants§
Text(String)
Owned text.
AnchoredText
Owned YAML text together with the name of an anchor to extract from it.
This is mainly intended for resolvers that support include specs such as
path/to/file.yaml#anchor_name. In that case, the resolver still receives the full
include spec via IncludeRequest::spec, splits the file part from the fragment itself,
reads the target document, and returns:
let source = InputSource::AnchoredText {
text: "defaults: &defaults\n enabled: true\nfeature: *defaults\n".to_owned(),
anchor: "defaults".to_owned(),
};During parsing, serde-saphyr will parse text, find the node tagged with &defaults,
and replay only that anchored node as the included value. Conceptually, this makes:
settings: !include config.yaml#defaultsbehave as if settings directly contained the YAML node anchored as &defaults inside
config.yaml.
Use InputSource::Text when the whole document should be included, and use
InputSource::AnchoredText only when you want the include to resolve to a specific
anchored fragment.
Reader(Box<dyn Read + 'static>)
Owned reader (streaming).