aboutsummaryrefslogtreecommitdiff
path: root/rustables/src/table.rs
diff options
context:
space:
mode:
authorla Fleur <lafleur@boum.org>2021-10-21 09:20:38 +0000
committerla Fleur <lafleur@boum.org>2021-10-21 09:20:38 +0000
commit762c778ddbc277891ecc8a4a180b4022c491b2a6 (patch)
tree04ee66e4a9cdeca5ddbb6060cf86f5a6ec5009c9 /rustables/src/table.rs
parent0f2a239b967080ea041c21779f063ca1afcc3d2c (diff)
parentfe4161f2c9717720463783090b88f390a7f67264 (diff)
Merge branch 'restrict-raw-handles' into 'master'
Hide all raw pointers manipulation by users behind an opt-in feature flag See merge request rustwall/rustables!2
Diffstat (limited to 'rustables/src/table.rs')
-rw-r--r--rustables/src/table.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/rustables/src/table.rs b/rustables/src/table.rs
index 447d035..dc09b5e 100644
--- a/rustables/src/table.rs
+++ b/rustables/src/table.rs
@@ -1,7 +1,8 @@
use crate::{MsgType, ProtoFamily};
use rustables_sys::{self as sys, libc};
+#[cfg(feature = "query")]
+use std::convert::TryFrom;
use std::{
- convert::TryFrom,
ffi::{c_void, CStr, CString},
fmt::Debug,
os::raw::c_char,
@@ -16,11 +17,6 @@ pub struct Table {
family: ProtoFamily,
}
-// Safety: It should be safe to pass this around and *read* from it
-// from multiple threads
-unsafe impl Send for Table {}
-unsafe impl Sync for Table {}
-
impl Table {
/// Creates a new table instance with the given name and protocol family.
pub fn new<T: AsRef<CStr>>(name: &T, family: ProtoFamily) -> Table {
@@ -84,11 +80,13 @@ impl Table {
}
}
+ #[cfg(feature = "unsafe-raw-handles")]
/// Returns the raw handle.
pub fn as_ptr(&self) -> *const sys::nftnl_table {
self.table as *const sys::nftnl_table
}
+ #[cfg(feature = "unsafe-raw-handles")]
/// Returns a mutable version of the raw handle.
pub fn as_mut_ptr(&self) -> *mut sys::nftnl_table {
self.table