Skip to content

Commit 341cb54

Browse files
d-e-s-odanielocfb
authored andcommitted
Revert "Remove strum_macros dependency"
This change reverts commit 2c27477 ("Remove strum_macros dependency") for us to release a bug fix release without breaking backwards compatibility. Signed-off-by: Daniel Müller <[email protected]>
1 parent 17133d6 commit 341cb54

File tree

6 files changed

+58
-23
lines changed

6 files changed

+58
-23
lines changed

Cargo.lock

Lines changed: 45 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/bpf_query/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn prog(args: ProgArgs) {
2727
let opts = query::ProgInfoQueryOptions::default().include_all();
2828
for prog in query::ProgInfoIter::with_query_opts(opts) {
2929
println!(
30-
"name={:<16} type={:<15?} run_count={:<2} runtime_ns={} recursion_misses={:<2}",
30+
"name={:<16} type={:<15} run_count={:<2} runtime_ns={} recursion_misses={:<2}",
3131
prog.name.to_string_lossy(),
3232
prog.ty,
3333
prog.run_cnt,
@@ -60,7 +60,7 @@ fn prog(args: ProgArgs) {
6060

6161
fn map() {
6262
for map in query::MapInfoIter::default() {
63-
println!("name={:<16} type={:?}", map.name.to_string_lossy(), map.ty);
63+
println!("name={:<16} type={}", map.name.to_string_lossy(), map.ty);
6464
}
6565
}
6666

libbpf-rs/CHANGELOG.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
Unreleased
2-
----------
3-
- Removed `Display` implementation of various `enum` types
4-
5-
61
0.23.2
72
------
83
- Fixed build failure on Android platforms

libbpf-rs/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ vendored = ["libbpf-sys/vendored"]
2727
bitflags = "2.0"
2828
libbpf-sys = { version = "1.4.1", default-features = false }
2929
libc = "0.2"
30+
strum_macros = "0.24"
3031
vsprintf = "2.0"
3132

3233
[dev-dependencies]

libbpf-rs/src/map.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use std::slice::from_raw_parts;
2323
use bitflags::bitflags;
2424
use libbpf_sys::bpf_map_info;
2525
use libbpf_sys::bpf_obj_get_info_by_fd;
26+
use strum_macros::Display;
2627

2728
use crate::util;
2829
use crate::util::parse_ret_i32;
@@ -315,7 +316,7 @@ impl Map {
315316
pub fn attach_struct_ops(&self) -> Result<Link> {
316317
if self.map_type() != MapType::StructOps {
317318
return Err(Error::with_invalid_data(format!(
318-
"Invalid map type ({:?}) for attach_struct_ops()",
319+
"Invalid map type ({}) for attach_struct_ops()",
319320
self.map_type(),
320321
)));
321322
}
@@ -634,7 +635,7 @@ impl MapHandle {
634635
}
635636
if self.map_type().is_percpu() {
636637
return Err(Error::with_invalid_data(format!(
637-
"lookup_percpu() must be used for per-cpu maps (type of the map is {:?})",
638+
"lookup_percpu() must be used for per-cpu maps (type of the map is {})",
638639
self.map_type(),
639640
)));
640641
}
@@ -673,7 +674,7 @@ impl MapHandle {
673674
pub fn lookup_percpu(&self, key: &[u8], flags: MapFlags) -> Result<Option<Vec<Vec<u8>>>> {
674675
if !self.map_type().is_percpu() && self.map_type() != MapType::Unknown {
675676
return Err(Error::with_invalid_data(format!(
676-
"lookup() must be used for maps that are not per-cpu (type of the map is {:?})",
677+
"lookup() must be used for maps that are not per-cpu (type of the map is {})",
677678
self.map_type(),
678679
)));
679680
}
@@ -801,7 +802,7 @@ impl MapHandle {
801802
pub fn update(&self, key: &[u8], value: &[u8], flags: MapFlags) -> Result<()> {
802803
if self.map_type().is_percpu() {
803804
return Err(Error::with_invalid_data(format!(
804-
"update_percpu() must be used for per-cpu maps (type of the map is {:?})",
805+
"update_percpu() must be used for per-cpu maps (type of the map is {})",
805806
self.map_type(),
806807
)));
807808
}
@@ -880,7 +881,7 @@ impl MapHandle {
880881
pub fn update_percpu(&self, key: &[u8], values: &[Vec<u8>], flags: MapFlags) -> Result<()> {
881882
if !self.map_type().is_percpu() && self.map_type() != MapType::Unknown {
882883
return Err(Error::with_invalid_data(format!(
883-
"update() must be used for maps that are not per-cpu (type of the map is {:?})",
884+
"update() must be used for maps that are not per-cpu (type of the map is {})",
884885
self.map_type(),
885886
)));
886887
}
@@ -980,7 +981,7 @@ bitflags! {
980981
// If you add a new per-cpu map, also update `is_percpu`.
981982
#[non_exhaustive]
982983
#[repr(u32)]
983-
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
984+
#[derive(Copy, Clone, PartialEq, Eq, Display, Debug)]
984985
// TODO: Document members.
985986
#[allow(missing_docs)]
986987
pub enum MapType {

libbpf-rs/src/program.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::ptr::NonNull;
1414
use std::slice;
1515

1616
use libbpf_sys::bpf_func_id;
17+
use strum_macros::Display;
1718

1819
use crate::util;
1920
use crate::AsRawLibbpf;
@@ -244,7 +245,7 @@ impl AsRawLibbpf for OpenProgram {
244245
/// Type of a [`Program`]. Maps to `enum bpf_prog_type` in kernel uapi.
245246
#[non_exhaustive]
246247
#[repr(u32)]
247-
#[derive(Copy, Clone, Debug)]
248+
#[derive(Copy, Clone, Display, Debug)]
248249
// TODO: Document variants.
249250
#[allow(missing_docs)]
250251
pub enum ProgramType {
@@ -359,7 +360,7 @@ impl From<u32> for ProgramType {
359360
/// Attach type of a [`Program`]. Maps to `enum bpf_attach_type` in kernel uapi.
360361
#[non_exhaustive]
361362
#[repr(u32)]
362-
#[derive(Clone, Debug)]
363+
#[derive(Clone, Display, Debug)]
363364
// TODO: Document variants.
364365
#[allow(missing_docs)]
365366
pub enum ProgramAttachType {

0 commit comments

Comments
 (0)