Skip to main content

XacroProcessor

Struct XacroProcessor 

Source
pub struct XacroProcessor { /* private fields */ }

Implementations§

Source§

impl XacroProcessor

Source

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();
Source

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\""));
Source

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);
    }
}
Source

pub fn run<P: AsRef<Path>>(&self, path: P) -> Result<String, XacroError>

Process xacro content from a file path

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for XacroProcessor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.