pub struct Module<'a> { /* private fields */ }Expand description
Borrowed handle to a resolved ModuleData.
Wraps a Mib reference and an arena id. Handles are Copy and
cheap to pass around. Two handles are equal when they point to the
same arena slot in the same Mib.
Implementations§
Source§impl<'a> Module<'a>
impl<'a> Module<'a>
Sourcepub fn language(self) -> Language
pub fn language(self) -> Language
Return the detected SMI language version.
Returns Language::Unknown when the available syntax and imports
provide insufficient or conflicting version evidence.
Sourcepub fn source_id(self) -> Option<SourceId>
pub fn source_id(self) -> Option<SourceId>
Return the compilation-local source identity, if this module came from source text.
Sourcepub fn source(self) -> Option<&'a SourceDocument>
pub fn source(self) -> Option<&'a SourceDocument>
Return the retained source document, if this module came from source text.
Sourcepub fn source_label(self) -> Option<&'a str>
pub fn source_label(self) -> Option<&'a str>
Return the source document’s display label, if retained.
Sourcepub fn source_origin(self) -> Option<&'a SourceOrigin>
pub fn source_origin(self) -> Option<&'a SourceOrigin>
Return the source document’s stable origin, if retained.
Sourcepub fn semantic_at(self, offset: ByteOffset) -> Option<SemanticSpan<'a>>
pub fn semantic_at(self, offset: ByteOffset) -> Option<SemanticSpan<'a>>
Return resolved semantic context at a byte offset in this module’s source.
Ranges are half-open: the start byte is included and the end byte is not.
References take precedence over containing definitions. Among overlapping
references, the narrowest range wins. Equal widths use import, OID, then
type/symbol-reference priority; equal-kind overlaps prefer the later start,
then retained-item order. Returns None for an out-of-bounds offset or a
module without retained source text.
Sourcepub fn semantic_at_source(
self,
source_id: SourceId,
offset: ByteOffset,
) -> Option<SemanticSpan<'a>>
pub fn semantic_at_source( self, source_id: SourceId, offset: ByteOffset, ) -> Option<SemanticSpan<'a>>
Return resolved semantic context after checking the source identity.
This is useful when a caller has a source-qualified cursor. A source ID
from another document never falls back to interpreting the same numeric
offset in this module and instead returns None.
Sourcepub fn semantic_at_position(
self,
position: Position,
encoding: PositionEncoding,
) -> Result<Option<SemanticSpan<'a>>, PositionError>
pub fn semantic_at_position( self, position: Position, encoding: PositionEncoding, ) -> Result<Option<SemanticSpan<'a>>, PositionError>
Return resolved semantic context at a zero-based editor position.
Position conversion uses the requested UTF encoding and propagates
invalid-line, invalid-column, mid-code-point, and invalid-UTF-8 errors.
A module without retained source text returns Ok(None).
Sourcepub fn semantic_at_source_position(
self,
source_id: SourceId,
position: Position,
encoding: PositionEncoding,
) -> Result<Option<SemanticSpan<'a>>, PositionError>
pub fn semantic_at_source_position( self, source_id: SourceId, position: Position, encoding: PositionEncoding, ) -> Result<Option<SemanticSpan<'a>>, PositionError>
Return resolved semantic context at a source-qualified editor position.
A source-ID mismatch returns Ok(None) without converting the position;
otherwise this has the same conversion errors and result as
Module::semantic_at_position.
Sourcepub fn organization(self) -> &'a str
pub fn organization(self) -> &'a str
Return the ORGANIZATION clause text from MODULE-IDENTITY.
Sourcepub fn contact_info(self) -> &'a str
pub fn contact_info(self) -> &'a str
Return the CONTACT-INFO clause text from MODULE-IDENTITY.
Sourcepub fn description(self) -> &'a str
pub fn description(self) -> &'a str
Return the DESCRIPTION clause text from MODULE-IDENTITY.
Sourcepub fn last_updated(self) -> &'a str
pub fn last_updated(self) -> &'a str
Return the LAST-UPDATED timestamp string from MODULE-IDENTITY.
Sourcepub fn identities(self) -> &'a [ModuleIdentityData]
pub fn identities(self) -> &'a [ModuleIdentityData]
Return exact module-scoped OID identity declarations.
This preserves same-OID aliases and declarations hidden by the global OID tree’s winning name, kind, metadata, or module.
Sourcepub fn is_base(self) -> bool
pub fn is_base(self) -> bool
Return true if this is an SMI foundation module (SNMPv2-SMI, etc.).
Foundation modules define the SMI language itself. Their source may be supplied by a configured source or by the parsed embedded fallback. See the crate-level docs for the full list and source precedence.
Sourcepub fn oid(self) -> Option<&'a Oid>
pub fn oid(self) -> Option<&'a Oid>
Return the module’s registered OID from its MODULE-IDENTITY, if any.
Sourcepub fn imports_symbol(self, name: &str) -> bool
pub fn imports_symbol(self, name: &str) -> bool
Return true if this module imports a symbol with the given name.
Sourcepub fn import_source(self, name: &str) -> Option<Module<'a>>
pub fn import_source(self, name: &str) -> Option<Module<'a>>
Return the resolved source module for an imported name.
Sourcepub fn import_resolution(self, name: &str) -> Option<&'a ImportResolution>
pub fn import_resolution(self, name: &str) -> Option<&'a ImportResolution>
Return retained pre-collapse resolution provenance for an imported symbol.
Sourcepub fn object(self, name: &str) -> Option<Object<'a>>
pub fn object(self, name: &str) -> Option<Object<'a>>
Look up an object defined by this module.
Sourcepub fn notification(self, name: &str) -> Option<Notification<'a>>
pub fn notification(self, name: &str) -> Option<Notification<'a>>
Look up a notification defined by this module.
Sourcepub fn compliance(self, name: &str) -> Option<Compliance<'a>>
pub fn compliance(self, name: &str) -> Option<Compliance<'a>>
Look up a compliance statement defined by this module.
Sourcepub fn capability(self, name: &str) -> Option<Capability<'a>>
pub fn capability(self, name: &str) -> Option<Capability<'a>>
Look up a capabilities statement defined by this module.
Sourcepub fn objects(self) -> impl Iterator<Item = Object<'a>> + 'a
pub fn objects(self) -> impl Iterator<Item = Object<'a>> + 'a
Iterate objects defined by this module.
Trait Implementations§
impl<'a> Copy for Module<'a>
impl Eq for Module<'_>
Auto Trait Implementations§
impl<'a> Freeze for Module<'a>
impl<'a> RefUnwindSafe for Module<'a>
impl<'a> Send for Module<'a>
impl<'a> Sync for Module<'a>
impl<'a> Unpin for Module<'a>
impl<'a> UnsafeUnpin for Module<'a>
impl<'a> UnwindSafe for Module<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.