Skip to main content

Source

Trait Source 

Source
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:

Required Methods§

Source

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).

Source

fn list_modules(&self) -> Result<Vec<String>>

List all module names available from this source.

The returned names should match what find accepts. Callers use this to discover modules when no explicit module list is provided to the loader.

§Errors

Returns io::Error if listing fails (e.g. directory read error).

Provided Methods§

Source

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".

Implementors§