diff options
| author | Edward Barnard | 2015-08-28 18:58:38 +0700 |
|---|---|---|
| committer | Edward Barnard | 2015-08-28 18:58:38 +0700 |
| commit | b5ad734bd68454fcb304a555bd2b1f0bb3274ec9 (patch) | |
| tree | 1a49349cb59211402d15d4e2335faca2a4385dae /src/binary.rs | |
| parent | 0c2ad6b0d12524b7042d45a92c1b20d8082c662c (diff) | |
| download | rust-plist-b5ad734bd68454fcb304a555bd2b1f0bb3274ec9.tar.bz2 | |
Add StartPlist and EndPlist events
Diffstat (limited to 'src/binary.rs')
| -rw-r--r-- | src/binary.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/binary.rs b/src/binary.rs index 826ba0b..c189c1a 100644 --- a/src/binary.rs +++ b/src/binary.rs @@ -119,9 +119,10 @@ impl<R: Read+Seek> StreamingParser<R> { } fn read_next(&mut self) -> ParserResult<Option<PlistEvent>> { - // Initialise here rather than in new if self.ref_size == 0 { + // Initialise here rather than in new try!(self.read_trailer()); + return Ok(Some(PlistEvent::StartPlist)) } let object_ref = match self.stack.last_mut() { @@ -140,7 +141,7 @@ impl<R: Read+Seek> StreamingParser<R> { match item.ty { StackType::Array => return Ok(Some(PlistEvent::EndArray)), StackType::Dict => return Ok(Some(PlistEvent::EndDictionary)), - StackType::Root => return Ok(None) // Reached the end of the plist + StackType::Root => return Ok(Some(PlistEvent::EndPlist)) } } } @@ -251,6 +252,7 @@ mod tests { let events: Vec<PlistEvent> = streaming_parser.collect(); let comparison = &[ + StartPlist, StartDictionary(Some(5)), StringValue("Lines".to_owned()), StartArray(Some(2)), @@ -265,7 +267,8 @@ mod tests { StringValue("William Shakespeare".to_owned()), StringValue("Data".to_owned()), DataValue(vec![0, 0, 0, 190, 0, 0, 0, 3, 0, 0, 0, 30, 0, 0, 0]), - EndDictionary + EndDictionary, + EndPlist ]; assert_eq!(events, comparison); |
