pub enum Error {
Show 14 variants
Io(Error),
Zip(ZipError),
Xml(Error),
XmlAttr(String),
MissingFile(String),
InvalidFormat(String),
InvalidXml(String),
InvalidModel(String),
OutsidePositiveOctant(usize, f64, f64, f64),
ParseError(String),
Unsupported(String),
UnsupportedExtension(String),
InvalidSecureContent(String),
XmlWrite(String),
}Expand description
Errors that can occur when parsing 3MF files
Variants§
Io(Error)
IO error occurred while reading the file
Error Code: E1001
Common Causes:
- File not found
- Insufficient permissions
- Disk read error
Zip(ZipError)
ZIP archive error
Error Code: E1002
Common Causes:
- Corrupted ZIP file
- Unsupported compression method
- Truncated archive
Suggestions:
- Verify the file is a valid 3MF (ZIP) archive
- Try re-downloading or re-exporting the file
Xml(Error)
XML parsing error
Error Code: E2001
Common Causes:
- Malformed XML syntax
- Invalid character encoding
- Unclosed tags
XmlAttr(String)
XML attribute error
Error Code: E2002
Common Causes:
- Missing required attribute
- Invalid attribute value
- Duplicate attribute
Suggestions:
- Check the 3MF specification for required attributes
- Verify attribute values are properly formatted
MissingFile(String)
Missing required file in the 3MF archive
Error Code: E1003
Common Causes:
- Incomplete 3MF package
- Missing 3D model file
- Missing content types file
Suggestions:
- Ensure the 3MF archive contains all required files
- Check for
[Content_Types].xmland3D/3dmodel.modelfiles
InvalidFormat(String)
Invalid 3MF format
Error Code: E2004
Common Causes:
- Non-compliant OPC structure
- Invalid content types
- Missing required OPC relationships
Suggestions:
- Verify the file was exported correctly
- Check the 3MF specification for OPC requirements
InvalidXml(String)
Invalid XML structure
Error Code: E2003
Common Causes:
- Missing required XML elements
- Elements in wrong order
- Invalid element nesting
Suggestions:
- Check element hierarchy matches 3MF specification
- Verify required child elements are present
InvalidModel(String)
Invalid model structure or validation failure
Error Code: E3001
Common Causes:
- Mesh topology errors (non-manifold, degenerate triangles)
- Invalid object references
- Out-of-bounds vertex indices
- Duplicate object IDs
Suggestions:
- Check mesh for manifold edges (each edge shared by at most 2 triangles)
- Verify all vertex indices are within bounds
- Ensure all object IDs are unique and positive
- Validate all references point to existing objects
OutsidePositiveOctant(usize, f64, f64, f64)
Geometry placed outside the positive octant
Error Code: E3003
Common Causes:
- Build item transforms place mesh vertices with negative coordinates
- Object positioned below build plate (negative Z)
- Object positioned with negative X or Y coordinates
Suggestions:
- Per 3MF spec, all coordinates must be non-negative (>= 0)
- Adjust build item transforms to ensure all geometry is in positive octant
- Check that final transformed coordinates (after applying transforms) are >= 0
Details: Object ID: {0}, Min coordinates: ({1:.2}, {2:.2}, {3:.2})
ParseError(String)
Parse error for numeric values
Error Code: E3002
Common Causes:
- Invalid number format
- Out-of-range values
- Non-numeric characters in numeric fields
Suggestions:
- Verify numeric values use proper format (e.g., “1.5” not “1,5”)
- Check for special characters or extra whitespace
Unsupported(String)
Unsupported feature or extension
Error Code: E4001
Common Causes:
- Using 3MF extensions not implemented by this parser
- Future 3MF specification features
Suggestions:
- Check if the feature is part of a 3MF extension
- Verify this parser supports the required extensions
UnsupportedExtension(String)
Required extension not supported
Error Code: E4002
Common Causes:
- 3MF file requires an extension not implemented by this parser
- Extension marked as required in the XML namespace
Suggestions:
- Check the file’s required extensions in the model XML
- Use a different parser that supports the required extension
- If possible, re-export without the extension
InvalidSecureContent(String)
Invalid SecureContent keystore
Error Code: E4003
Common Causes:
- Invalid consumer index reference (EPX-2601)
- Missing consumer element when accessright is defined (EPX-2602)
- Invalid encryption algorithm (EPX-2603)
- Duplicate consumer IDs (EPX-2604)
- Invalid encrypted file path (EPX-2605)
- Missing required keystore elements (EPX-2606)
- Referenced file doesn’t exist in package (EPX-2607)
Suggestions:
- Verify the keystore.xml follows the 3MF SecureContent specification
- Check consumer definitions and accessright references
- Ensure all referenced files exist in the package
XmlWrite(String)
XML writing error
Error Code: E2005
Common Causes:
- Failed to serialize XML
- Invalid data for XML writing
- I/O error during writing
Suggestions:
- Check that data structures are valid
- Ensure output stream is writable
Implementations§
Source§impl Error
impl Error
Sourcepub fn error_type(&self) -> &'static str
pub fn error_type(&self) -> &'static str
Get the error type as a string for matching against expected failures
This returns a stable identifier for the error variant, useful for testing and validation purposes.
Sourcepub fn invalid_xml_element(element: &str, message: &str) -> Self
pub fn invalid_xml_element(element: &str, message: &str) -> Self
Sourcepub fn missing_attribute(element: &str, attribute: &str) -> Self
pub fn missing_attribute(element: &str, attribute: &str) -> Self
Sourcepub fn invalid_format_context(context: &str, message: &str) -> Self
pub fn invalid_format_context(context: &str, message: &str) -> Self
Create an InvalidFormat error with context about what file/structure is invalid
§Arguments
context- What part of the format is invalid (e.g., “OPC structure”, “Content types”)message- Description of the error
Sourcepub fn parse_error_with_context(
field_name: &str,
value: &str,
expected_type: &str,
) -> Self
pub fn parse_error_with_context( field_name: &str, value: &str, expected_type: &str, ) -> Self
Create a ParseError with context about what was being parsed
§Arguments
field_name- The name of the field being parsed (e.g., “vertex x coordinate”)value- The value that failed to parseexpected_type- The expected type (e.g., “floating-point number”)
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<ParseFloatError> for Error
impl From<ParseFloatError> for Error
Source§fn from(err: ParseFloatError) -> Self
fn from(err: ParseFloatError) -> Self
Source§impl From<ParseIntError> for Error
impl From<ParseIntError> for Error
Source§fn from(err: ParseIntError) -> Self
fn from(err: ParseIntError) -> Self
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl !UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.