Skip to content

Commit

Permalink
maps: sort variants
Browse files Browse the repository at this point in the history
  • Loading branch information
tamird committed Sep 27, 2023
1 parent 023ae99 commit f04f2d0
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions aya/src/maps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ pub enum MapError {
}

// Note that this is not just derived using #[from] because InvalidMapTypeError cannot implement
// Error due the the fact that aya-obj is nostd and error_in_core is not stabilized
// Error due the the fact that aya-obj is no_std and error_in_core is not stabilized
// (https://github.com/rust-lang/rust/issues/103765).
impl From<InvalidMapTypeError> for MapError {
fn from(e: InvalidMapTypeError) -> Self {
Expand Down Expand Up @@ -253,70 +253,70 @@ fn maybe_warn_rlimit() {
pub enum Map {
/// An [`Array`] map.
Array(MapData),
/// A [`PerCpuArray`] map.
PerCpuArray(MapData),
/// A [`ProgramArray`] map.
ProgramArray(MapData),
/// A [`BloomFilter`] map.
BloomFilter(MapData),
/// A [`CpuMap`] map.
CpuMap(MapData),
/// A [`DevMap`] map.
DevMap(MapData),
/// A [`DevMapHash`] map.
DevMapHash(MapData),
/// A [`HashMap`] map.
HashMap(MapData),
/// A [`PerCpuHashMap`] map.
PerCpuHashMap(MapData),
/// A [`LpmTrie`] map.
LpmTrie(MapData),
/// A [`HashMap`] map that uses a LRU eviction policy.
LruHashMap(MapData),
/// A [`PerCpuArray`] map
PerCpuArray(MapData),
/// A [`PerCpuHashMap`] map
PerCpuHashMap(MapData),
/// A [`PerCpuHashMap`] map that uses a LRU eviction policy.
PerCpuLruHashMap(MapData),
/// A [`PerfEventArray`] map.
PerfEventArray(MapData),
/// A [`SockMap`] map.
SockMap(MapData),
/// A [`ProgramArray`] map.
ProgramArray(MapData),
/// A [`Queue`] map.
Queue(MapData),
/// A [`SockHash`] map.
SockHash(MapData),
/// A [`BloomFilter`] map.
BloomFilter(MapData),
/// A [`LpmTrie`] map.
LpmTrie(MapData),
/// A [`SockMap`] map.
SockMap(MapData),
/// A [`Stack`] map.
Stack(MapData),
/// A [`StackTraceMap`] map.
StackTraceMap(MapData),
/// A [`Queue`] map.
Queue(MapData),
/// A [`CpuMap`] map.
CpuMap(MapData),
/// A [`DevMap`] map.
DevMap(MapData),
/// A [`DevMapHash`] map.
DevMapHash(MapData),
/// A [`XskMap`] map.
XskMap(MapData),
/// An unsupported map type.
Unsupported(MapData),
/// A [`XskMap`] map.
XskMap(MapData),
}

impl Map {
/// Returns the low level map type.
fn map_type(&self) -> u32 {
match self {
Self::Array(map) => map.obj.map_type(),
Self::PerCpuArray(map) => map.obj.map_type(),
Self::ProgramArray(map) => map.obj.map_type(),
Self::BloomFilter(map) => map.obj.map_type(),
Self::CpuMap(map) => map.obj.map_type(),
Self::DevMap(map) => map.obj.map_type(),
Self::DevMapHash(map) => map.obj.map_type(),
Self::HashMap(map) => map.obj.map_type(),
Self::LpmTrie(map) => map.obj.map_type(),
Self::LruHashMap(map) => map.obj.map_type(),
Self::PerCpuArray(map) => map.obj.map_type(),
Self::PerCpuHashMap(map) => map.obj.map_type(),
Self::PerCpuLruHashMap(map) => map.obj.map_type(),
Self::PerfEventArray(map) => map.obj.map_type(),
Self::ProgramArray(map) => map.obj.map_type(),
Self::Queue(map) => map.obj.map_type(),
Self::SockHash(map) => map.obj.map_type(),
Self::SockMap(map) => map.obj.map_type(),
Self::BloomFilter(map) => map.obj.map_type(),
Self::LpmTrie(map) => map.obj.map_type(),
Self::Stack(map) => map.obj.map_type(),
Self::StackTraceMap(map) => map.obj.map_type(),
Self::Queue(map) => map.obj.map_type(),
Self::CpuMap(map) => map.obj.map_type(),
Self::DevMap(map) => map.obj.map_type(),
Self::DevMapHash(map) => map.obj.map_type(),
Self::XskMap(map) => map.obj.map_type(),
Self::Unsupported(map) => map.obj.map_type(),
Self::XskMap(map) => map.obj.map_type(),
}
}
}
Expand Down Expand Up @@ -371,13 +371,13 @@ macro_rules! impl_try_from_map {
}

impl_try_from_map!(() {
ProgramArray,
SockMap,
PerfEventArray,
StackTraceMap,
CpuMap,
DevMap,
DevMapHash,
PerfEventArray,
ProgramArray,
SockMap,
StackTraceMap,
XskMap,
});

Expand All @@ -389,17 +389,17 @@ impl_try_from_map!(() {

impl_try_from_map!((V) {
Array,
PerCpuArray,
SockHash,
BloomFilter,
PerCpuArray,
Queue,
SockHash,
Stack,
});

impl_try_from_map!((K, V) {
HashMap from HashMap|LruHashMap,
PerCpuHashMap from PerCpuHashMap|PerCpuLruHashMap,
LpmTrie,
PerCpuHashMap from PerCpuHashMap|PerCpuLruHashMap,
});

pub(crate) fn check_bounds(map: &MapData, index: u32) -> Result<(), MapError> {
Expand Down

0 comments on commit f04f2d0

Please sign in to comment.