pub struct Writer<W: Write> { /* private fields */ }Expand description
An XML writer.
Implementations§
Source§impl<W: Write> Writer<W>
impl<W: Write> Writer<W>
Sourcepub fn with_options(writer: W, options: Options) -> Self
pub fn with_options(writer: W, options: Options) -> Self
Creates a new Writer that will write into writer with the specified options.
Sourcepub fn write_start(
&mut self,
prefix: Option<&str>,
name: &str,
) -> Result<(), Error>
pub fn write_start( &mut self, prefix: Option<&str>, name: &str, ) -> Result<(), Error>
Writes a start tag with the specified prefix and name into the writer.
§Errors
Returns an error if the prefix or name is invalid or an underlying I/O error occurs.
Sourcepub fn write_empty(
&mut self,
prefix: Option<&str>,
name: &str,
) -> Result<(), Error>
pub fn write_empty( &mut self, prefix: Option<&str>, name: &str, ) -> Result<(), Error>
Writes an empty tag with the specified prefix and name into the writer.
§Errors
Returns an error if the prefix or name is invalid or an underlying I/O error occurs.
Sourcepub fn write_raw_attribute(
&mut self,
name: &str,
quote: AttributeQuote,
value: &str,
) -> Result<(), Error>
pub fn write_raw_attribute( &mut self, name: &str, quote: AttributeQuote, value: &str, ) -> Result<(), Error>
Writes an attribute with the specified prefix and name into the writer.
The attribute will use the double quote as the quote character.
Does not escape the value but will return an error if is improperly escaped.
Must only be called in the context of a start tag, i.e. after a successful Self::write_start, Self::write_empty, Self::write_raw_attribute, or Self::write_attribute.
§Errors
Returns an error if the name or value is invalid or an underlying I/O error occurs.
Sourcepub fn write_attribute(&mut self, name: &str, value: &str) -> Result<(), Error>
pub fn write_attribute(&mut self, name: &str, value: &str) -> Result<(), Error>
Writes an attribute with the specified prefix and name into the writer.
The attribute will use the double quote as the quote character.
Must only be called in the context of a start tag, i.e. after a successful Self::write_start, Self::write_empty, Self::write_raw_attribute, or Self::write_attribute.
§Errors
Returns an error if the name is invalid or an underlying I/O error occurs.
Sourcepub fn write_end(
&mut self,
prefix: Option<&str>,
name: &str,
) -> Result<(), Error>
pub fn write_end( &mut self, prefix: Option<&str>, name: &str, ) -> Result<(), Error>
Writes an end tag with the specified prefix and name into the writer.
§Errors
Returns an error if the prefix or name is invalid or an underlying I/O error occurs.
Sourcepub fn write_raw_text(&mut self, text: &str) -> Result<(), Error>
pub fn write_raw_text(&mut self, text: &str) -> Result<(), Error>
Writes text content into the writer.
§Errors
Returns an error if the content is improperly escaped or contains a null byte or an underlying I/O error occurs.