pub struct XacroProcessor { /* private fields */ }Implementations§
Source§impl XacroProcessor
impl XacroProcessor
Sourcepub fn builder() -> XacroBuilder
pub fn builder() -> XacroBuilder
Create a new builder for configuring the processor.
§Example
use xacro_rs::XacroProcessor;
let processor = XacroProcessor::builder()
.with_arg("robot_name", "my_robot")
.with_max_depth(100)
.build();Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new xacro processor with default settings.
For custom configuration, use XacroProcessor::builder().
§Example
use xacro_rs::XacroProcessor;
let processor = XacroProcessor::new();
let input = r#"<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="test">
<xacro:property name="value" value="42"/>
<link name="base"><inertial><mass value="${value}"/></inertial></link>
</robot>"#;
let output = processor.run_from_string(input)?;
assert!(output.contains("mass value=\"42\""));Sourcepub fn extensions(&self) -> &[Box<dyn ExtensionHandler>]
pub fn extensions(&self) -> &[Box<dyn ExtensionHandler>]
Get a reference to the registered extension handlers.
This allows callers to inspect or downcast extensions for observability purposes (e.g., extracting package resolution info from FindExtension).
§Example
use xacro_rs::{XacroProcessor, FindExtension};
let processor = XacroProcessor::new();
processor.run("robot.xacro")?;
// Extract package info from FindExtension
for ext in processor.extensions().iter() {
if let Some(find_ext) = ext.as_any().downcast_ref::<FindExtension>() {
let packages = find_ext.get_found_packages();
println!("Found packages: {:?}", packages);
}
}Sourcepub fn run<P: AsRef<Path>>(&self, path: P) -> Result<String, XacroError>
pub fn run<P: AsRef<Path>>(&self, path: P) -> Result<String, XacroError>
Process xacro content from a file path
Sourcepub fn run_with_deps<P: AsRef<Path>>(
&self,
path: P,
) -> Result<(String, Vec<PathBuf>), XacroError>
pub fn run_with_deps<P: AsRef<Path>>( &self, path: P, ) -> Result<(String, Vec<PathBuf>), XacroError>
Process xacro content from a file path and return included files
Returns a tuple of (processed_output, included_files).
The included_files list contains paths to all files that were included
during processing via <xacro:include> directives.
Sourcepub fn run_from_string(&self, content: &str) -> Result<String, XacroError>
pub fn run_from_string(&self, content: &str) -> Result<String, XacroError>
Process xacro content from a string
§Note
Any <xacro:include> directives with relative paths will be resolved
relative to the current working directory.
Sourcepub fn run_from_string_with_deps(
&self,
content: &str,
) -> Result<(String, Vec<PathBuf>), XacroError>
pub fn run_from_string_with_deps( &self, content: &str, ) -> Result<(String, Vec<PathBuf>), XacroError>
Process xacro content from a string and return included files
Returns a tuple of (processed_output, included_files).
The included_files list contains paths to all files that were included
during processing via <xacro:include> directives.
§Note
Any <xacro:include> directives with relative paths will be resolved
relative to the current working directory.