build(deps): adapt 3MF reader to quick-xml 0.42

This commit is contained in:
Preetinder Kalsi authored and Irakli Kourtis committed 2026-10-15 13:12:49 -04:00
1 parent f220c7108b
commit e3d42d8be1
4 files changed
+29 -19

No files matched your search

Generated
+12 -3
View File
@@ -1355,7 +1355,7 @@ name = "fieldcraft-geometry"
version = "0.5.9"
dependencies = [
"fieldcraft-model",
"quick-xml",
"quick-xml 0.42.0",
"serde_json",
"solidcraft-doc",
"solidcraft-engine",
@@ -3087,6 +3087,15 @@ dependencies = [
"memchr",
]
[[package]]
name = "quick-xml"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41b1177fdf999d2321d3fb46ff47159d9c1fb9ad66a4879f8c50a0b504615e9b"
dependencies = [
"memchr",
]
[[package]]
name = "quote"
version = "1.0.47"
@@ -3837,7 +3846,7 @@ name = "solidcraft-io"
version = "0.11.0"
source = "git+https://github.com/bherbruck/solidcraft?rev=b1695873f5d0031f51a8d5e7ec036fced6f000e2#b1695873f5d0031f51a8d5e7ec036fced6f000e2"
dependencies = [
"quick-xml",
"quick-xml 0.41.0",
"serde",
"serde_json",
"sha2 0.10.9",
@@ -4698,7 +4707,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "338e30461b3a2b67d70eb30a6d89f8e0c93a833e07d2ae89085cd070c4a00ac0"
dependencies = [
"proc-macro2",
"quick-xml",
"quick-xml 0.41.0",
"quote",
]
+2 -2
View File
@@ -35,9 +35,9 @@ serde = { version = "1", features = ["derive"] }
serde_json = { version = "1", features = ["float_roundtrip"] }
log = "0.4"
# 3MF packages (docs/formats/tagged-mesh.md): the same versions SolidCraft uses.
# 3MF packages (docs/formats/tagged-mesh.md).
zip = { version = "3", default-features = false, features = ["deflate"] }
quick-xml = "0.41"
quick-xml = "0.42"
# content hashes and part checksums of .fieldcraft files (the version SolidCraft uses)
sha2 = "0.11"
+3 -2
View File
@@ -1,6 +1,6 @@
Third-party software in FieldCraft
FieldCraft (the desktop app, fieldcraft-cli and the web app) is built from the 477 crates below.
FieldCraft (the desktop app, fieldcraft-cli and the web app) is built from the 478 crates below.
Generated by `cargo xtask licences` from Cargo.lock and the crates' own licence files.
FieldCraft's own licence is in LICENSE-MIT and LICENSE-APACHE, and NOTICE.
@@ -268,6 +268,7 @@ profiling 1.0.18 (MIT OR Apache-2.0)
pxfm 0.1.30 (BSD-3-Clause OR Apache-2.0)
quick-error 2.0.1 (MIT/Apache-2.0)
quick-xml 0.41.0 (MIT)
quick-xml 0.42.0 (MIT)
quote 1.0.47 (MIT OR Apache-2.0)
r-efi 5.3.0 (MIT OR Apache-2.0 OR LGPL-2.1-or-later)
r-efi 6.0.0 (MIT OR Apache-2.0 OR LGPL-2.1-or-later)
@@ -9233,7 +9234,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================================================
quick-xml 0.41.0
quick-xml 0.41.0, quick-xml 0.42.0
================================================================================
The MIT License (MIT)
+12 -12
View File
@@ -35,7 +35,7 @@ use fieldcraft_model::MAX_COORD;
/// flattens the object (relative, so a uniform scale is never refused).
const MIN_RELATIVE_DET: f64 = 1e-12;
const CORE_NS: &[u8] = b"http://schemas.microsoft.com/3dmanufacturing/core/2015/02";
const CORE_NS: &str = "http://schemas.microsoft.com/3dmanufacturing/core/2015/02";
/// SolidCraft's face-tag namespace, version 1.
pub const FACE_TAGS_NS: &str = "https://github.com/bherbruck/solidcraft/formats/3mf-face-tags/2026/10";
@@ -85,7 +85,7 @@ enum Ns {
fn ns_of(r: &ResolveResult) -> Ns {
match r {
ResolveResult::Bound(n) if n.as_ref() == CORE_NS => Ns::Core,
ResolveResult::Bound(n) if n.as_ref() == FACE_TAGS_NS.as_bytes() => Ns::FaceTags,
ResolveResult::Bound(n) if n.as_ref() == FACE_TAGS_NS => Ns::FaceTags,
ResolveResult::Unbound => Ns::Core,
_ => Ns::Other,
}
@@ -93,7 +93,7 @@ fn ns_of(r: &ResolveResult) -> Ns {
/// An element's attributes as (namespace, local name, value), borrowed from the event (values
/// are copied only when they hold entity references). Unprefixed attributes are Core.
type Attrs<'a> = Vec<(Ns, &'a [u8], Cow<'a, str>)>;
type Attrs<'a> = Vec<(Ns, &'a str, Cow<'a, str>)>;
fn attrs<'a, R>(rd: &NsReader<R>, e: &'a BytesStart) -> Result<Attrs<'a>> {
let mut out = Vec::with_capacity(4);
@@ -107,7 +107,7 @@ fn attrs<'a, R>(rd: &NsReader<R>, e: &'a BytesStart) -> Result<Attrs<'a>> {
}
fn get<'s>(a: &'s Attrs, ns: Ns, key: &str) -> Option<&'s str> {
a.iter().find(|(n, k, _)| *n == ns && *k == key.as_bytes()).map(|(_, _, v)| v.as_ref())
a.iter().find(|(n, k, _)| *n == ns && *k == key).map(|(_, _, v)| v.as_ref())
}
fn int(a: &Attrs, ns: Ns, key: &str, what: &str) -> Result<Option<u32>> {
@@ -216,7 +216,7 @@ fn parse_model(xml: &[u8]) -> Result<Model> {
Event::End(end) => {
depth = depth.saturating_sub(1);
if ns == Ns::Core
&& end.local_name().as_ref() == b"object"
&& end.local_name().as_ref() == "object"
&& let Some((id, o)) = cur.take()
{
m.add(id, o)?;
@@ -237,13 +237,13 @@ fn parse_model(xml: &[u8]) -> Result<Model> {
}
let a = attrs(&rd, &e)?;
match e.local_name().as_ref() {
b"model" => {
"model" => {
seen_model = true;
if let Some(u) = get(&a, Ns::Core, "unit") {
m.unit = unit_mm(u).ok_or_else(|| invalid(format!("unknown unit `{u}`")))?;
}
}
b"object" => {
"object" => {
if cur.is_some() {
return bad("an object inside an object");
}
@@ -262,7 +262,7 @@ fn parse_model(xml: &[u8]) -> Result<Model> {
cur = Some((id, o));
}
}
b"vertex" => {
"vertex" => {
let Some((_, o)) = cur.as_mut() else { return bad("vertex outside an object") };
vertices += 1;
if vertices > MAX_ELEMENTS {
@@ -270,7 +270,7 @@ fn parse_model(xml: &[u8]) -> Result<Model> {
}
o.positions.push([coord(&a, "x")?, coord(&a, "y")?, coord(&a, "z")?]);
}
b"triangle" => {
"triangle" => {
let Some((id, o)) = cur.as_mut() else { return bad("triangle outside an object") };
triangles += 1;
if triangles > MAX_ELEMENTS {
@@ -288,11 +288,11 @@ fn parse_model(xml: &[u8]) -> Result<Model> {
}
o.triangles.push(t);
}
b"component" => {
"component" => {
let Some((_, o)) = cur.as_mut() else { return bad("component outside an object") };
o.components = true;
}
b"item" => {
"item" => {
if m.build.len() >= MAX_BUILD_ITEMS {
return bad(format!("more than {MAX_BUILD_ITEMS} build items"));
}
@@ -364,7 +364,7 @@ pub fn read_3mf(bytes: &[u8]) -> Result<Vec<TaggedSurface>> {
let mut buf = Vec::new();
loop {
match rd.read_event_into(&mut buf) {
Ok(Event::Start(e)) | Ok(Event::Empty(e)) if e.local_name().as_ref() == b"Relationship" => {
Ok(Event::Start(e)) | Ok(Event::Empty(e)) if e.local_name().as_ref() == "Relationship" => {
let a = attrs(&rd, &e)?;
if get(&a, Ns::Core, "Type").is_some_and(|t| t.ends_with("/3dmodel"))
&& let Some(t) = get(&a, Ns::Core, "Target")