Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maps: sort variants #813

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 38 additions & 38 deletions aya/src/maps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,70 +243,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 @@ -442,13 +442,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 @@ -460,17 +460,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