Skip to content

Commit

Permalink
Fix xmls with binary data blobs
Browse files Browse the repository at this point in the history
Thanks to quick-xml for pushing the update to trimming text ends:
tafia/quick-xml#253.
  • Loading branch information
elrnv committed Feb 3, 2021
1 parent 363d972 commit 5c232d4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 21 deletions.
8 changes: 3 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,17 @@ specifically between parse and write functions).
Support for compression and decompression (feature gated by the "compression" feature which is
enabled by default) are also added.

- LZMA, LZ4 and Zlib compression are now all supported for base64 encoded appended data blobs.
- LZMA, LZ4 and Zlib compression are now all supported for appended data blobs.
- Compression level is currently ignored on LZ4 until either the `lz4_flex` crate implements
support, or the `lz4` crate supports LZ4 block format.
- Binary appended data blobs are currently not supported until
[#253](https://github.com/tafia/quick-xml/pull/253) is merged into the `quick-xml` crate.
- Note that solutions to either of the above problems should only cause a minor version bumb.
- Note that solutions to the above problem should only cause a minor version bump.

A few new API changes have been made:

- The VTK file was changed to include an optional `file_path`, which encodes the original path to the
VTK file. This allows relative paths when reading in "parallel" XML files. This is how
ParaView deals with "parallel" XML files for instance. Note that the "parallel" files refers to how
they are defined in the VTK documentation; async file loading is not yet supprted, but it is planned.
they are defined in the VTK documentation; async file loading is not yet supported, but it is planned.
- `load_piece_data` was renamed to `into_loaded_piece_data` to indicate that this function takes a
piece by value and converts it into concrete piece data.
- In contrast `load_piece_in_place` takes a Piece by mutable reference and replaces source pieces by
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vtkio"
version = "0.6.0"
version = "0.6.1"
authors = ["Egor Larionov <egor.larionov@gmail.com>"]
license = "MIT OR Apache-2.0"
description = "Parser and writer for the legacy VTK file format"
Expand Down Expand Up @@ -29,7 +29,7 @@ bytemuck = { version = "1.5", features = ["extern_crate_alloc"] }
lz4 = { package = "lz4_flex", version = "0.7", optional = true }
flate2 = { version = "1.0.19", optional = true }
xz2 = { version = "0.1.6", optional = true }
quick-xml = { version = "0.20", features = ["serialize"], optional = true }
quick-xml = { version = "0.21", features = ["serialize"], optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
tokio = { version = "0.3", features = ["fs", "io-util"], optional = true }

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Error::IO(source) => Some(source),
Error::Write(_) => None, // TODO: implement std::error for writer::Error
Error::Write(source) => Some(source),
Error::Parse(_) => None,
#[cfg(feature = "xml")]
Error::XML(source) => Some(source),
Expand Down
5 changes: 2 additions & 3 deletions src/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3474,9 +3474,8 @@ fn de_from_reader(reader: impl BufRead) -> Result<VTKFile> {
reader
.expand_empty_elements(true)
.check_end_names(true)
.trim_text(true);
//TODO: Uncomment when https://github.com/tafia/quick-xml/pull/253 is merged
//.trim_text_end(false);
.trim_text(true)
.trim_text_end(false);
let mut de = de::Deserializer::new(reader);
Ok(VTKFile::deserialize(&mut de)?)
}
Expand Down
19 changes: 9 additions & 10 deletions tests/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,15 @@ fn hexahedron_zlib() -> Result {
Ok(())
}

// TODO: Will not work until https://github.com/tafia/quick-xml/pull/253 is merged.
//#[cfg(feature = "compression")]
//#[test]
//fn hexahedron_zlib_binary() -> Result {
// let mut vtu = import("./assets/hexahedron_zlib_binary.vtu")?;
// vtu.load_all_pieces().unwrap();
// vtu.file_path = None;
// assert_eq!(vtu, make_hexahedron_vtu());
// Ok(())
//}
#[cfg(feature = "compression")]
#[test]
fn hexahedron_zlib_binary() -> Result {
let mut vtu = Vtk::import("./assets/hexahedron_zlib_binary.vtu")?;
vtu.load_all_pieces().unwrap();
vtu.file_path = None;
assert_eq!(vtu, make_hexahedron_vtu());
Ok(())
}

#[cfg(feature = "compression")]
#[test]
Expand Down

0 comments on commit 5c232d4

Please # to comment.