Skip to main content

Module wasm_dir_scan

Module wasm_dir_scan 

Source
Expand description

Shared .wasm directory scanner.

Both crate::PluginManager::register_wasm_dir and rustledger_importer::ImporterRegistry::register_wasm_dir walk a directory looking for .wasm files to register. (The latter isn’t an intra-doc link because that crate sits downstream of this one in the dep graph — link from text on the importer side instead.) The two used to be near-copies — same listing, filtering, sorting, and per-entry error handling logic, only the error wrapping and per-file load fn differed. This module factors out the shared listing-and-filtering step.

§What’s shared

  • read_dir + iteration
  • is_file() + case-insensitive .wasm extension filter
  • Per-entry I/O errors collected (not propagated, so a single permission-denied inode doesn’t abort the scan)
  • Lexicographic sort by path so load order is deterministic across filesystems and platforms

§What stays caller-side

  • Dir-level read_dir error wrapping: each caller has its own error type and preferred context message (“failed to read plugin dir …” vs WasmImporterError::Io).
  • Per-file load: the importer calls register_wasm_from_path, the plugin manager calls load. Their return values and error shapes are different (importer returns the module’s declared name; plugin returns an index + uses the registered Plugin’s name()).

Both kept caller-side because forcing them through a generic adapter would add more code than it saved.

Structs§

WasmDirScan
Outcome of collect_wasm_paths.

Functions§

collect_wasm_paths
Collect .wasm files from dir (one level, no recursion) and sort them lexicographically.