pub trait ExtensionHandler: Send + Sync {
// Required methods
fn extension_type(&self) -> Extension;
fn validate(&self, model: &Model) -> Result<()>;
// Provided methods
fn namespace(&self) -> &'static str { ... }
fn name(&self) -> &'static str { ... }
fn is_used_in_model(&self, _model: &Model) -> bool { ... }
fn pre_write(&self, _model: &mut Model) -> Result<()> { ... }
fn post_parse(&self, _model: &mut Model) -> Result<()> { ... }
}Expand description
Handler trait for 3MF extensions
This trait defines the interface that all extension handlers must implement. It provides hooks for parsing, validation, and writing extension-specific data.
§Example
ⓘ
struct MyExtensionHandler;
impl ExtensionHandler for MyExtensionHandler {
fn extension_type(&self) -> Extension {
Extension::Material
}
fn validate(&self, model: &Model) -> Result<()> {
// Perform extension-specific validation
Ok(())
}
}Required Methods§
Sourcefn extension_type(&self) -> Extension
fn extension_type(&self) -> Extension
Returns the extension type this handler supports
Provided Methods§
Sourcefn is_used_in_model(&self, _model: &Model) -> bool
fn is_used_in_model(&self, _model: &Model) -> bool
Check if the extension is present in the model
This method can be used to determine if the model actually uses this extension.
The default implementation always returns true, but extensions can override
this to provide more specific detection.
§Arguments
model- The 3MF model to check
§Returns
trueif the extension is used in the modelfalseotherwise