diff --git a/aya/src/maps/mod.rs b/aya/src/maps/mod.rs index dcbca570..e25e6f44 100644 --- a/aya/src/maps/mod.rs +++ b/aya/src/maps/mod.rs @@ -306,6 +306,18 @@ impl Drop for Map { } } +/// Allows the Fd of a loaded [`Map`] to be retrieved +pub trait MapFd { + /// Returns the [`RawFd`] of the program if it has been loaded, or `None` + fn fd(&self) -> Option<RawFd>; +} + +impl MapFd for Map { + fn fd(&self) -> Option<RawFd> { + self.fd + } +} + /// An iterable map pub trait IterableMap<K: Pod, V> { /// Get a generic map handle