Skip to main content

extract_resources

Function extract_resources 

Source
pub fn extract_resources() -> Result<TempDir, DataError>
Expand description

Extracts all embedded resources to a temporary directory.

This creates a temporary directory and writes all embedded resources to it, preserving the directory structure. The returned TempDir will automatically clean up when dropped.

Use this when you need file-system access to the resources, for example when interfacing with C libraries that expect file paths.

§Errors

Returns a DataError if:

  • The temporary directory cannot be created
  • A subdirectory cannot be created
  • A file cannot be written

§Example

use verovioxide_data::extract_resources;

let temp_dir = extract_resources().expect("Failed to extract resources");
let bravura_path = temp_dir.path().join("Bravura.xml");
assert!(bravura_path.exists());

// Use the resources...

// TempDir is automatically cleaned up when dropped