Enum sise::NodeReadUtil [−][src]
pub enum NodeReadUtil<'a, R: Reader> {
Atom(AtomReadUtil<R>),
List(ListReadUtil<'a, R>),
}
Expand description
Utility to read nodes from a Reader
.
Variants
Atom(AtomReadUtil<R>)
Tuple Fields of Atom
0: AtomReadUtil<R>
List(ListReadUtil<'a, R>)
Tuple Fields of List
0: ListReadUtil<'a, R>
Implementations
Reads from reader
and builds a ReadUtil::Atom
or
ReadUtil::List
according to the result. Panics if the
reader returns ReadItemKind::ListEnding
.
Consumes self
and returns an AtomReadUtil
if it is an atom,
otherwise it returns a ReadUtilError::ExpectedAtom
.
Example
let src_data = "example";
let mut parser = sise::Parser::new(src_data);
let mut node_read_util = sise::NodeReadUtil::new(&mut parser).unwrap();
let atom_read_util = node_read_util.expect_atom().unwrap();
assert_eq!(atom_read_util.into_atom(), "example");
Consumes self
and returns an AtomReadUtil
if it is a list,
otherwise it returns a ReadUtilError::ExpectedListBeginning
.
Example
let src_data = "()";
let mut parser = sise::Parser::new(src_data);
let node_read_util = sise::NodeReadUtil::new(&mut parser).unwrap();
let mut list_read_util = node_read_util.expect_list().unwrap();