mirror of
https://github.com/mbilker/kbinxml-rs.git
synced 2026-09-09 19:15:27 -05:00
lib: expose parsing to a NodeCollection
This commit is contained in:
11
src/lib.rs
11
src/lib.rs
@@ -309,13 +309,18 @@ impl KbinXml {
|
||||
kbinxml.from_binary_internal(input)
|
||||
}
|
||||
|
||||
pub fn node_from_binary(input: &[u8]) -> Result<(Node, EncodingType)> {
|
||||
pub fn node_collection_from_binary(input: &[u8]) -> Result<(NodeCollection, EncodingType)> {
|
||||
let mut reader = Reader::new(input)?;
|
||||
let collection = NodeCollection::from_iter(&mut reader).ok_or(KbinErrorKind::InvalidState)?;
|
||||
|
||||
let node = collection.as_node()?;
|
||||
let encoding = reader.encoding();
|
||||
|
||||
Ok((collection, encoding))
|
||||
}
|
||||
|
||||
pub fn node_from_binary(input: &[u8]) -> Result<(Node, EncodingType)> {
|
||||
let (collection, encoding) = Self::node_collection_from_binary(input)?;
|
||||
let node = collection.as_node()?;
|
||||
|
||||
Ok((node, encoding))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user