pub trait Source: Send + Sync {
// Required methods
fn find(&self, name: &str) -> Result<Option<SourceCandidate>>;
fn list_modules(&self) -> Result<Vec<String>>;
// Provided method
fn find_candidates<'a>(
&'a self,
name: &'a str,
) -> Box<dyn Iterator<Item = Result<SourceCandidate>> + 'a> { ... }
}Expand description
Provides access to MIB files for the loading pipeline.
Implementations must be Send + Sync to support parallel loading.
The library ships several constructors:
file()/files()- individual files on diskdir/dir_with_config- directory tree on diskdirs()- multiple directory trees combinedmemory/memory_modules- in-memory contentchain- combine arbitrary sources in priority order
Required Methods§
Sourcefn find(&self, name: &str) -> Result<Option<SourceCandidate>>
fn find(&self, name: &str) -> Result<Option<SourceCandidate>>
Look up a module by name and return its first document candidate.
Returns Ok(None) if this source does not contain the named module.
The name parameter is the MIB module name (e.g. "IF-MIB"), not a
filename.
§Errors
Returns io::Error if the underlying storage cannot be read (for
example, a file I/O failure or permission denial).
Sourcefn list_modules(&self) -> Result<Vec<String>>
fn list_modules(&self) -> Result<Vec<String>>
Provided Methods§
Sourcefn find_candidates<'a>(
&'a self,
name: &'a str,
) -> Box<dyn Iterator<Item = Result<SourceCandidate>> + 'a>
fn find_candidates<'a>( &'a self, name: &'a str, ) -> Box<dyn Iterator<Item = Result<SourceCandidate>> + 'a>
Iterate over candidates for a module name in precedence order.
Candidates and their I/O errors are produced lazily. This lets callers stop after validating an earlier candidate without accessing lower priority storage. Each candidate supplies a stable provider-scoped identity; returning the same identity for multiple requested names associates those names with one physical document. Custom sources that expose at most one candidate can rely on this default implementation.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".