[][src]Struct sdlang::Tag

pub struct Tag {
    pub namespace: Option<String>,
    pub name: String,
    pub values: Vec<Value>,
    pub attrs: Vec<Attribute>,
    pub tags: Vec<Tag>,
}

A series of values and attributes, with a name (and namespace), and optionally a subtree of tags.

All data in SDLang is stored through these.

Fields

namespace: Option<String>

The namespace (if any) of the tag.

name: String

The name of the tag. "" if none was given.

values: Vec<Value>

A list of values.

attrs: Vec<Attribute>

A list of attributes.

tags: Vec<Tag>

A list of subtags (empty vector if none exist).

Methods

impl Tag[src]

pub fn new(name: String) -> Self[src]

Creates a new tag.

Note that no allocation is performed. Everything is initialised to a default empty state.

pub fn namespace(self, namespace: String) -> Self[src]

Sets the namespace.

pub fn values(self, values: Vec<Value>) -> Self[src]

Sets the value list.

pub fn attrs(self, attrs: Vec<Attribute>) -> Self[src]

Sets the attribute list from a list of Attributes.

pub fn tags(self, tags: Vec<Tag>) -> Self[src]

Sets the child tags.

pub fn attr<'a, 'b>(&'a self, name: &'b str) -> Option<&'a Attribute>[src]

Finds the given attribute by name.

pub fn attr_mut<'a, 'b>(
    &'a mut self,
    name: &'b str
) -> Option<&'a mut Attribute>
[src]

Finds the given attribute by name, returning a mutable reference.

pub fn tag<'a, 'b>(&'a self, name: &'b str) -> Option<&'a Tag>[src]

Finds the given subtag by name.

pub fn tag_mut<'a, 'b>(&'a mut self, name: &'b str) -> Option<&'a mut Tag>[src]

Finds the given tag by name, returning a mutable reference.

Trait Implementations

impl PartialEq<Tag> for Tag[src]

impl Display for Tag[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

Returns a human-readable representation of the tag. The format is roughly this:

tag "<namespace>:<name>": <values>, <attributes>
* <subtag_1>
  * <subtag_1_subtag>
  * ...
* <subtag_2>
* ...

impl Debug for Tag[src]

impl FromStr for Tag[src]

type Err = Error

The associated error which can be returned from parsing.

fn from_str(s: &str) -> Result<Self>[src]

Parses the text for a Tag, returning a parse error on failure.

Auto Trait Implementations

impl Send for Tag

impl Sync for Tag

Blanket Implementations

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.