pub struct ElementBuilder { /* private fields */ }
Expand description
An Element Builder, building Element
s from Event
s as produced by Parser
use xml::{Parser, ElementBuilder};
let mut parser = Parser::new();
let mut builder = ElementBuilder::new();
parser.feed_str("<example/>");
for result in parser.filter_map(|event| builder.handle_event(event)) {
println!("{}", result.unwrap());
}
Implementations§
source§impl ElementBuilder
impl ElementBuilder
sourcepub fn new() -> ElementBuilder
pub fn new() -> ElementBuilder
Returns a new ElementBuilder
sourcepub fn define_prefix(&mut self, prefix: String, ns: String)
pub fn define_prefix(&mut self, prefix: String, ns: String)
Bind a prefix to a namespace
sourcepub fn set_default_ns(&mut self, ns: String)
pub fn set_default_ns(&mut self, ns: String)
Set the default namespace
sourcepub fn handle_event(
&mut self,
e: Result<Event, ParserError>,
) -> Option<Result<Element, BuilderError>>
pub fn handle_event( &mut self, e: Result<Event, ParserError>, ) -> Option<Result<Element, BuilderError>>
Let the builder process an Event
to ultimately build an Element
.
While no root element has been finished None
is returned.
Once sufficent data has been received an Element
is returned as Some(Ok(elem))
.
Upon Error Some(Err("message"))
is returned.
Auto Trait Implementations§
impl Freeze for ElementBuilder
impl RefUnwindSafe for ElementBuilder
impl Send for ElementBuilder
impl Sync for ElementBuilder
impl Unpin for ElementBuilder
impl UnwindSafe for ElementBuilder
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