[][src]Struct fbxcel::pull_parser::v7400::Parser

pub struct Parser<R> { /* fields omitted */ }

Pull parser for FBX 7.4 binary or compatible later versions.

Methods

impl<R: ParserSource> Parser<R>[src]

pub const PARSER_VERSION: ParserVersion[src]

Parser version.

pub fn set_warning_handler<F>(&mut self, warning_handler: F) where
    F: 'static + FnMut(Warning, &SyntacticPosition) -> Result<()>, 
[src]

Sets the warning handler.

Examples

let mut parser = fbxcel::pull_parser::v7400::from_reader(header, reader)
    .expect("Failed to create parser");
parser.set_warning_handler(|warning, pos| {
    // Print warning.
    eprintln!("WARNING: {} (pos={:?})", warning, pos);
    // To ignore the warning and continue processing, return `Ok(())`.
    // To treat the given warning as a critical error, return
    // `Err(warning.into())`.
    Ok(())
});

pub fn fbx_version(&self) -> FbxVersion[src]

Returns FBX version.

pub fn current_node_name(&self) -> &str[src]

Returns the name of the current node.

Panics

This panics if there are no open nodes.

pub fn current_depth(&self) -> usize[src]

Returns current node depth.

Implicit root node is considered to be depth 0.

pub fn next_event(&mut self) -> Result<Event<R>>[src]

Returns next event if successfully read.

You should not call next_event() if a parser functionality has been already failed and returned error. If you call next_event() with failed parser, error created from OperationError::AlreadyAborted will be returned.

pub fn skip_current_node(&mut self) -> Result<()>[src]

Ignore events until the current node closes.

In other words, this discards parser events including EndNode for the current node.

This method seeks to the already known node end position, without parsing events to be ignored. Because of this, some errors can be overlooked, or some errors can be detected at the different position from the true error position.

To detect errors correctly, you should use [next_event] manually.

Panics

Panics if there are no open nodes.

Examples

let mut parser = fbxcel::pull_parser::v7400::from_reader(header, reader)
    .expect("Failed to create parser");
// Do something here.
// Something done.
let depth = parser.current_depth();
parser.skip_current_node().expect("Failed to skip current node");
assert_eq!(parser.current_depth(), depth - 1);

pub fn position(&self) -> SyntacticPosition[src]

Returns the syntactic position of the current node.

Note that this allocates memory.

pub fn is_used(&self) -> bool[src]

Returns whether the parser is already used or brand-new.

Returns true if the parser emitted some events in the past, returns false if the parser have not emitted any events.

Examples

let mut parser = fbxcel::pull_parser::v7400::from_reader(header, reader)
    .expect("Failed to create parser");
assert!(!parser.is_used());
parser.set_warning_handler(|warning, pos| {
    // Print warning.
    eprintln!("WARNING: {} (pos={:?})", warning, pos);
    // To ignore the warning and continue processing, return `Ok(())`.
    // To treat the given warning as a critical error, return
    // `Err(warning.into())`.
    Ok(())
});
assert!(!parser.is_used(), "Parser emitted no events yet");
let _ = parser.next_event();
assert!(parser.is_used(), "Parser emitted an event");

Trait Implementations

impl<R: Debug> Debug for Parser<R>[src]

Auto Trait Implementations

impl<R> !Send for Parser<R>

impl<R> !Sync for Parser<R>

Blanket Implementations

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

impl<T, U> TryInto 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> Any for T where
    T: 'static + ?Sized
[src]