aboutsummaryrefslogtreecommitdiff
path: root/nftnl/src
diff options
context:
space:
mode:
Diffstat (limited to 'nftnl/src')
-rw-r--r--nftnl/src/batch.rs2
-rw-r--r--nftnl/src/lib.rs16
2 files changed, 6 insertions, 12 deletions
diff --git a/nftnl/src/batch.rs b/nftnl/src/batch.rs
index 8998f16..e6e95a5 100644
--- a/nftnl/src/batch.rs
+++ b/nftnl/src/batch.rs
@@ -78,7 +78,7 @@ impl Batch {
fn next(&mut self) -> Result<()> {
if unsafe { sys::nftnl_batch_update(self.batch) } < 0 {
- return Err(crate::Error::AllocationError);
+ return Err(crate::AllocationError(()));
}
self.seq += 1;
Ok(())
diff --git a/nftnl/src/lib.rs b/nftnl/src/lib.rs
index 8a990cf..1d51258 100644
--- a/nftnl/src/lib.rs
+++ b/nftnl/src/lib.rs
@@ -42,24 +42,18 @@ pub use nftnl_sys;
use nftnl_sys::libc::c_void;
-pub type Result<T> = std::result::Result<T, Error>;
+pub type Result<T> = std::result::Result<T, AllocationError>;
+/// Unable to allocate memory
#[derive(err_derive::Error, Debug)]
-pub enum Error {
- /// Unable to allocate memory
- #[error(display = "Unable to allocate memory")]
- AllocationError,
-
- /// Not enough room in the batch
- #[error(display = "Not enough room in the batch")]
- BatchIsFull,
-}
+#[error(display = "Unable to allocate memory")]
+pub struct AllocationError(());
macro_rules! try_alloc {
($e:expr) => {{
let ptr = $e;
if ptr.is_null() {
- return Err($crate::Error::AllocationError);
+ return Err($crate::AllocationError(()));
}
ptr
}};