aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2019-04-03 10:38:45 +0200
committerLinus Färnstrand <linus@mullvad.net>2019-04-03 10:38:45 +0200
commit69c853f314f66018aae6a7bd8768e100d2cd9d58 (patch)
treebe956e07e5761348c5b7bed0d82aa9115f1e42ff
parent9d596d522fc66f0c150877eeb68095790b2985ae (diff)
Remove unused error variant
-rw-r--r--nftnl/examples/add-rules.rs4
-rw-r--r--nftnl/examples/filter-ethernet.rs4
-rw-r--r--nftnl/src/batch.rs2
-rw-r--r--nftnl/src/lib.rs16
4 files changed, 10 insertions, 16 deletions
diff --git a/nftnl/examples/add-rules.rs b/nftnl/examples/add-rules.rs
index 8221b74..cfa43cb 100644
--- a/nftnl/examples/add-rules.rs
+++ b/nftnl/examples/add-rules.rs
@@ -204,8 +204,8 @@ fn socket_recv<'a>(socket: &mnl::Socket, buf: &'a mut [u8]) -> Result<Option<&'a
#[derive(Debug)]
struct Error(String);
-impl From<nftnl::Error> for Error {
- fn from(error: nftnl::Error) -> Self {
+impl From<nftnl::AllocationError> for Error {
+ fn from(error: nftnl::AllocationError) -> Self {
Error(error.to_string())
}
}
diff --git a/nftnl/examples/filter-ethernet.rs b/nftnl/examples/filter-ethernet.rs
index 1dbf71a..5b5bcbc 100644
--- a/nftnl/examples/filter-ethernet.rs
+++ b/nftnl/examples/filter-ethernet.rs
@@ -125,8 +125,8 @@ fn socket_recv<'a>(socket: &mnl::Socket, buf: &'a mut [u8]) -> Result<Option<&'a
#[derive(Debug)]
struct Error(String);
-impl From<nftnl::Error> for Error {
- fn from(error: nftnl::Error) -> Self {
+impl From<nftnl::AllocationError> for Error {
+ fn from(error: nftnl::AllocationError) -> Self {
Error(error.to_string())
}
}
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
}};