#[non_exhaustive]pub struct TagSource<'a> {
pub form: TagForm,
pub handle: &'a str,
pub suffix: &'a str,
pub span: Span,
/* private fields */
}Expand description
A tag property as written, before it is resolved (Sourced::tag_source,
crate::tree::Node::tag_source).
Resolving builds the full tag text, whose %TAG
prefix may be long. Two tags of one source with equal TagSource::keys
resolve to the same text, so a consumer can resolve each distinct tag
once (TagSource::resolve) and share the result; reading a
TagSource costs only the property’s own text.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.form: TagFormHow the tag was written.
handle: &'a strThe handle as written (!, !!, !e!); empty for verbatim tags.
suffix: &'a strThe suffix as written; for verbatim tags, the text between < and >.
span: SpanSpan of the whole property (in the text it was read from).
Implementations§
Source§impl<'a> TagSource<'a>
impl<'a> TagSource<'a>
Sourcepub fn key(&self) -> TagKey<'a>
pub fn key(&self) -> TagKey<'a>
What this tag resolves to, as a hashable key: O(1) to build, and
O(handle + suffix) to hash, whatever the %TAG prefix’s length.
Sourcepub fn resolve(&self) -> Option<Tag<'a>>
pub fn resolve(&self) -> Option<Tag<'a>>
The tag, resolved (%TAG prefix and %XX escapes, §6.9.1): what
Sourced::tag gives. O(prefix + suffix).
Sourcepub fn prefix_key(&self) -> Option<TagKey<'a>>
pub fn prefix_key(&self) -> Option<TagKey<'a>>
When the handle names a %TAG directive: the key of that
directive’s prefix, equal for every tag using it (to decode
TagSource::directive_prefix once and share it).
Sourcepub fn directive_prefix(&self) -> Option<Cow<'a, [u8]>>
pub fn directive_prefix(&self) -> Option<Cow<'a, [u8]>>
When the handle names a %TAG directive: its prefix with the
%XX escapes decoded, as bytes (a character may continue in the
suffix). O(prefix).
Sourcepub fn default_prefix(&self) -> Option<&'static str>
pub fn default_prefix(&self) -> Option<&'static str>
The prefix of a shorthand tag whose handle names no %TAG
directive: ! for the primary handle, tag:yaml.org,2002: for the
secondary one (§6.8.2.2). None otherwise (a verbatim or
non-specific tag, or one with a TagSource::directive_prefix).
Sourcepub fn decoded_suffix(&self) -> Cow<'a, [u8]>
pub fn decoded_suffix(&self) -> Cow<'a, [u8]>
The suffix (for a verbatim tag, its whole text) with the %XX
escapes decoded, as bytes (a character may begin in the prefix).
O(suffix). The resolved tag is the prefix
(TagSource::directive_prefix or TagSource::default_prefix)
followed by these bytes; together they are UTF-8.