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

Replace err_derive dependency with manual impl of Display + Error #59

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion nftnl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ nftnl-1-1-2 = ["nftnl-sys/nftnl-1-1-2"]

[dependencies]
bitflags = "1.0.4"
err-derive = "0.3.1"
log = "0.4"
nftnl-sys = { path = "../nftnl-sys", version = "0.6.1" }

Expand Down
12 changes: 10 additions & 2 deletions nftnl/src/batch.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
use crate::{MsgType, NlMsg};
use core::fmt;
use nftnl_sys::{self as sys, libc};
use std::ffi::c_void;
use std::os::raw::c_char;
use std::ptr;

/// Error while communicating with netlink
#[derive(err_derive::Error, Debug)]
#[error(display = "Error while communicating with netlink")]
#[derive(Debug)]
pub struct NetlinkError(());

impl fmt::Display for NetlinkError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
"Error while communicating with netlink".fmt(f)
}
}

impl std::error::Error for NetlinkError {}

/// Check if the kernel supports batched netlink messages to netfilter.
pub fn batch_is_supported() -> std::result::Result<bool, NetlinkError> {
match unsafe { sys::nftnl_batch_is_supported() } {
Expand Down