Skip to main content

TagBuilder

Struct TagBuilder 

Source
pub struct TagBuilder<'a> { /* private fields */ }
Expand description

Utility for servers to build custom opening tags.

§Examples

let mut builder = mxp::node::TagBuilder::new("monster");
builder
    .push("hostile")
    .push_all(&["Minotaur", "old veteran"])
    .insert("hp", "150");
let tag = builder.build();
assert_eq!(
    tag.to_string(),
    r#"<monster hostile Minotaur "old veteran" hp=150>"#
);

Implementations§

Source§

impl<'a> TagBuilder<'a>

A server-side utility for building opening tags.

Source

pub fn new(name: &'a str) -> Self

Creates a builder for an opening tag with the specified element name.

Source

pub fn build(self) -> TagOpen<'a, Cow<'a, str>>

Converts this builder into a finalized TagOpen.

Source

pub fn push(&mut self, value: &'a str) -> &mut Self

Adds a positional argument or keyword without escaping special characters.

Source

pub fn escape_and_push(&mut self, value: &'a str) -> &mut Self

Adds a positional argument or keyword after escaping special characters.

Source

pub fn push_all<I>(&mut self, iter: I) -> &mut Self
where I: IntoIterator, I::Item: Borrow<&'a str>,

Adds multiple positional arguments or keywords without escaping special characters.

Source

pub fn escape_and_push_all<I>(&mut self, iter: I) -> &mut Self
where I: IntoIterator, I::Item: Borrow<&'a str>,

Adds multiple positional arguments or keywords after escaping special characters.

Source

pub fn insert(&mut self, name: &'a str, value: &'a str) -> &mut Self

Inserts a named argument without escaping special characters.

Source

pub fn escape_and_insert(&mut self, name: &'a str, value: &'a str) -> &mut Self

Inserts a named argument after escaping special characters.

Source

pub fn insert_all<I, K, V>(&mut self, iter: I) -> &mut Self
where I: IntoIterator, I::Item: Borrow<(K, V)>, K: Borrow<&'a str>, V: Borrow<&'a str>,

Inserts multiple named arguments without escaping special characters.

Source

pub fn escape_and_insert_all<I, K, V>(&mut self, iter: I) -> &mut Self
where I: IntoIterator, I::Item: Borrow<(K, V)>, K: Borrow<&'a str>, V: Borrow<&'a str>,

Inserts multiple named arguments after escaping special characters.

Source

pub fn set_empty(&mut self, empty: bool) -> &mut Self

Tag will end with a '/' character, indicating that is empty.

Trait Implementations§

Source§

impl<'a> Clone for TagBuilder<'a>

Source§

fn clone(&self) -> TagBuilder<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for TagBuilder<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for TagBuilder<'a>

Source§

fn eq(&self, other: &TagBuilder<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for TagBuilder<'a>

Source§

impl<'a> StructuralPartialEq for TagBuilder<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for TagBuilder<'a>

§

impl<'a> RefUnwindSafe for TagBuilder<'a>

§

impl<'a> Send for TagBuilder<'a>

§

impl<'a> Sync for TagBuilder<'a>

§

impl<'a> Unpin for TagBuilder<'a>

§

impl<'a> UnsafeUnpin for TagBuilder<'a>

§

impl<'a> UnwindSafe for TagBuilder<'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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.