[][src]Struct quick_xml::events::BytesStart

pub struct BytesStart<'a> { /* fields omitted */ }

Opening tag data (Event::Start), with optional attributes.

<name attr="value">.

The name can be accessed using the name, local_name or unescaped methods. An iterator over the attributes is returned by the attributes method.

Implementations

impl<'a> BytesStart<'a>[src]

pub fn borrowed(content: &'a [u8], name_len: usize) -> Self[src]

Creates a new BytesStart from the given content (name + attributes).

Warning

&content[..name_len] is not checked to be a valid name

pub fn borrowed_name(name: &'a [u8]) -> BytesStart<'a>[src]

Creates a new BytesStart from the given name.

Warning

&content is not checked to be a valid name

pub fn owned<C: Into<Vec<u8>>>(
    content: C,
    name_len: usize
) -> BytesStart<'static>
[src]

Creates a new BytesStart from the given content (name + attributes)

Owns its contents.

pub fn owned_name<C: Into<Vec<u8>>>(name: C) -> BytesStart<'static>[src]

Creates a new BytesStart from the given name

Owns its contents.

pub fn into_owned(self) -> BytesStart<'static>[src]

Converts the event into an owned event.

pub fn to_owned(&self) -> BytesStart<'static>[src]

Converts the event into an owned event without taking ownership of Event

pub fn to_borrowed(&self) -> BytesStart<'_>[src]

Converts the event into a borrowed event. Most useful when paired with to_end.

Example

use quick_xml::events::{BytesStart, Event};

struct SomeStruct<'a> {
    attrs: BytesStart<'a>,
    // ...
}

writer.write_event(Event::Start(self.attrs.to_borrowed()))?;
// ...
writer.write_event(Event::End(self.attrs.to_end()))?;

pub fn to_end(&self) -> BytesEnd<'_>[src]

Creates new paired close tag

pub fn with_attributes<'b, I>(self, attributes: I) -> Self where
    I: IntoIterator,
    I::Item: Into<Attribute<'b>>, 
[src]

Consumes self and yield a new BytesStart with additional attributes from an iterator.

The yielded items must be convertible to Attribute using Into.

pub fn name(&self) -> &[u8][src]

Gets the undecoded raw tag name as a &[u8].

pub fn local_name(&self) -> &[u8][src]

Gets the undecoded raw local tag name (excluding namespace) as a &[u8].

All content up to and including the first : character is removed from the tag name.

pub fn unescaped(&self) -> Result<Cow<'_, [u8]>>[src]

Gets the unescaped tag name.

XML escape sequences like "&lt;" will be replaced by their unescaped characters like "<".

pub fn attributes(&self) -> Attributes<'_>

Notable traits for Attributes<'a>

impl<'a> Iterator for Attributes<'a> type Item = Result<Attribute<'a>>;
[src]

Returns an iterator over the attributes of this tag.

pub fn html_attributes(&self) -> Attributes<'_>

Notable traits for Attributes<'a>

impl<'a> Iterator for Attributes<'a> type Item = Result<Attribute<'a>>;
[src]

Returns an iterator over the HTML-like attributes of this tag (no mandatory quotes or =).

pub fn attributes_raw(&self) -> &[u8][src]

Gets the undecoded raw string with the attributes of this tag as a &[u8], including the whitespace after the tag name if there is any.

pub fn extend_attributes<'b, I>(&mut self, attributes: I) -> &mut BytesStart<'a> where
    I: IntoIterator,
    I::Item: Into<Attribute<'b>>, 
[src]

Add additional attributes to this tag using an iterator.

The yielded items must be convertible to Attribute using Into.

pub fn unescape_and_decode<B: BufRead>(
    &self,
    reader: &Reader<B>
) -> Result<String>
[src]

Returns the unescaped and decoded string value.

This allocates a String in all cases. For performance reasons it might be a better idea to instead use one of:

  • unescaped(), as it doesn't allocate when no escape sequences are used.
  • Reader::decode(), as it only allocates when the decoding can't be performed otherwise.

pub fn push_attribute<'b, A: Into<Attribute<'b>>>(&mut self, attr: A)[src]

Adds an attribute to this element.

pub fn set_name(&mut self, name: &[u8]) -> &mut BytesStart<'a>[src]

Edit the name of the BytesStart in-place

Warning

name is not checked to be a valid name

pub fn clear_attributes(&mut self) -> &mut BytesStart<'a>[src]

Remove all attributes from the ByteStart

Trait Implementations

impl<'a> Clone for BytesStart<'a>[src]

impl<'a> Debug for BytesStart<'a>[src]

impl<'a> Deref for BytesStart<'a>[src]

type Target = [u8]

The resulting type after dereferencing.

Auto Trait Implementations

impl<'a> RefUnwindSafe for BytesStart<'a>

impl<'a> Send for BytesStart<'a>

impl<'a> Sync for BytesStart<'a>

impl<'a> Unpin for BytesStart<'a>

impl<'a> UnwindSafe for BytesStart<'a>

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.