pub struct BindingLoader;Expand description
Loads .binding.yaml files into ScannedModule objects.
§Usage
let loader = BindingLoader;
let modules = loader.load(Path::new("bindings/"), false, false)?;
let strict = loader.load(Path::new("foo.binding.yaml"), true, false)?;In loose mode (strict=false, default), only module_id and target
are required; missing optional fields fall back to defaults.
In strict mode (strict=true), input_schema and output_schema are
additionally required.
Implementations§
Source§impl BindingLoader
impl BindingLoader
Sourcepub fn load(
&self,
path: &Path,
strict: bool,
recursive: bool,
) -> Result<Vec<ScannedModule>, BindingLoadError>
pub fn load( &self, path: &Path, strict: bool, recursive: bool, ) -> Result<Vec<ScannedModule>, BindingLoadError>
Load one file or every *.binding.yaml in a directory.
When recursive is true, subdirectories are traversed depth-first using
walkdir. When false (default), only the immediate directory is scanned.
§OS error handling vs. TypeScript
Note: unlike the TypeScript implementation which warns and continues on OS
permission errors (EACCES/EPERM), this implementation propagates any IO error
as BindingLoadError::FileRead and aborts the entire load. This is the
fail-fast behavior.
Sourcepub fn load_data(
&self,
data: &Value,
strict: bool,
) -> Result<Vec<ScannedModule>, BindingLoadError>
pub fn load_data( &self, data: &Value, strict: bool, ) -> Result<Vec<ScannedModule>, BindingLoadError>
Parse a pre-loaded binding JSON value ({"bindings": [...]}).