Struct tvix_eval::builtins::to_xml::XmlEmitter

source ·
struct XmlEmitter<W> {
    cur_indent: usize,
    writer: W,
    context: NixContext,
}
Expand description

A simple-stupid XML emitter, which implements only the subset needed for byte-by-byte compat with C++ nix’ builtins.toXML.

Fields§

§cur_indent: usize

The current indentation

§writer: W§context: NixContext

Implementations§

source§

impl<W: Write> XmlEmitter<W>

source

pub fn new(writer: W) -> Self

source

pub fn write_open_tag( &mut self, name_unescaped: &str, attrs: &[(&str, &str)], ) -> Result<()>

Write an open tag with the given name (which is not escaped!) and attributes (Keys are not escaped! Only attribute values are.)

source

pub fn write_self_closing_tag( &mut self, name_unescaped: &str, attrs: &[(&str, &str)], ) -> Result<()>

Write a self-closing open tag with the given name (which is not escaped!) and attributes (Keys are not escaped! Only attribute values are.)

source

pub fn write_closing_tag(&mut self, name_unescaped: &str) -> Result<()>

Write a closing tag with the given name (which is not escaped!)

source

fn add_indent(&mut self) -> Result<()>

source

fn write_attrs_escape_vals(&mut self, attrs: &[(&str, &str)]) -> Result<()>

Write an attribute list

source

fn escape_attr_value(s: &str) -> Cow<'_, str>

Escape the given attribute value, making sure we only actually clone the string if we needed to replace something.

source

fn should_escape_char(c: char) -> Option<&'static str>

source

fn extend_context<T>(&mut self, iter: T)

Extends the existing context with more context elements.

source

fn into_context(self) -> NixContext

Consumes Self and returns the NixContext collected.

Auto Trait Implementations§

§

impl<W> Freeze for XmlEmitter<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for XmlEmitter<W>
where W: RefUnwindSafe,

§

impl<W> Send for XmlEmitter<W>
where W: Send,

§

impl<W> Sync for XmlEmitter<W>
where W: Sync,

§

impl<W> Unpin for XmlEmitter<W>
where W: Unpin,

§

impl<W> UnwindSafe for XmlEmitter<W>
where W: UnwindSafe,

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> 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V