Skip to main content

TagSource

Struct TagSource 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§form: TagForm

How the tag was written.

§handle: &'a str

The handle as written (!, !!, !e!); empty for verbatim tags.

§suffix: &'a str

The suffix as written; for verbatim tags, the text between < and >.

§span: Span

Span of the whole property (in the text it was read from).

Implementations§

Source§

impl<'a> TagSource<'a>

Source

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.

Source

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).

Source

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).

Source

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).

Source

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).

Source

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.

Trait Implementations§

Source§

impl<'a> Clone for TagSource<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for TagSource<'a>

Source§

impl<'a> Debug for TagSource<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for TagSource<'a>

§

impl<'a> RefUnwindSafe for TagSource<'a>

§

impl<'a> Send for TagSource<'a>

§

impl<'a> Sync for TagSource<'a>

§

impl<'a> Unpin for TagSource<'a>

§

impl<'a> UnsafeUnpin for TagSource<'a>

§

impl<'a> UnwindSafe for TagSource<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.