[][src]Enum sise::NodeReadUtil

pub enum NodeReadUtil<'a, R: Reader> {
    Atom(AtomReadUtil<R>),
    List(ListReadUtil<'a, R>),
}

Utility to read nodes from a Reader.

Variants

Atom(AtomReadUtil<R>)
List(ListReadUtil<'a, R>)

Methods

impl<'a, R: Reader> NodeReadUtil<'a, R>[src]

pub fn new(reader: &'a mut R) -> Result<Self, R::Error>[src]

Reads from reader and builds a ReadUtil::Atom or ReadUtil::List according to the result. Panics if the reader returns ReadItemKind::ListEnding.

pub fn expect_atom(
    self
) -> Result<AtomReadUtil<R>, ReadUtilError<R::Error, R::Pos>>
[src]

Consumes self and returns an AtomReadUtil if it is an atom, otherwise it returns a ReadUtilError::ExpectedAtom.

Example

let src_data = b"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");

pub fn expect_list(
    self
) -> Result<ListReadUtil<'a, R>, ReadUtilError<R::Error, R::Pos>>
[src]

Consumes self and returns an AtomReadUtil if it is a list, otherwise it returns a ReadUtilError::ExpectedListBeginning.

Example

let src_data = b"()";
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();

Auto Trait Implementations

impl<'a, R> Send for NodeReadUtil<'a, R> where
    R: Send,
    <R as Reader>::Pos: Send,
    <R as Reader>::String: Send

impl<'a, R> Sync for NodeReadUtil<'a, R> where
    R: Sync,
    <R as Reader>::Pos: Sync,
    <R as Reader>::String: Sync

impl<'a, R> Unpin for NodeReadUtil<'a, R> where
    <R as Reader>::Pos: Unpin,
    <R as Reader>::String: Unpin

impl<'a, R> !UnwindSafe for NodeReadUtil<'a, R>

impl<'a, R> RefUnwindSafe for NodeReadUtil<'a, R> where
    R: RefUnwindSafe,
    <R as Reader>::Pos: RefUnwindSafe,
    <R as Reader>::String: RefUnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]