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+ iterationis_file()+ case-insensitive.wasmextension 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_direrror wrapping: each caller has its own error type and preferred context message (“failed to read plugin dir …” vsWasmImporterError::Io). - Per-file load: the importer calls
register_wasm_from_path, the plugin manager callsload. Their return values and error shapes are different (importer returns the module’s declared name; plugin returns an index + uses the registered Plugin’sname()).
Both kept caller-side because forcing them through a generic adapter would add more code than it saved.
Structs§
- Wasm
DirScan - Outcome of
collect_wasm_paths.
Functions§
- collect_
wasm_ paths - Collect
.wasmfiles fromdir(one level, no recursion) and sort them lexicographically.