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>
impl<W: Write> XmlEmitter<W>
pub fn new(writer: W) -> Self
sourcepub fn write_open_tag(
&mut self,
name_unescaped: &str,
attrs: &[(&str, &str)]
) -> Result<()>
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.)
sourcepub fn write_self_closing_tag(
&mut self,
name_unescaped: &str,
attrs: &[(&str, &str)]
) -> Result<()>
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.)
sourcepub fn write_closing_tag(&mut self, name_unescaped: &str) -> Result<()>
pub fn write_closing_tag(&mut self, name_unescaped: &str) -> Result<()>
Write a closing tag with the given name (which is not escaped!)
fn add_indent(&mut self) -> Result<()>
sourcefn write_attrs_escape_vals(&mut self, attrs: &[(&str, &str)]) -> Result<()>
fn write_attrs_escape_vals(&mut self, attrs: &[(&str, &str)]) -> Result<()>
Write an attribute list
sourcefn escape_attr_value(s: &str) -> Cow<'_, str>
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.
fn should_escape_char(c: char) -> Option<&'static str>
sourcefn extend_context<T>(&mut self, iter: T)where
T: IntoIterator<Item = NixContextElement>,
fn extend_context<T>(&mut self, iter: T)where
T: IntoIterator<Item = NixContextElement>,
Extends the existing context with more context elements.
sourcefn into_context(self) -> NixContext
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more