diff options
author | Simon THOBY <git@nightmared.fr> | 2021-10-19 23:41:07 +0200 |
---|---|---|
committer | lafleur <lafleur@boum.org> | 2021-10-20 11:04:51 +0200 |
commit | 0cea8e9638faf3f92fd9d42e85f543673c84a1c7 (patch) | |
tree | 24c9c15574693eb3e606169f6cb383c157d4481d /rustables/src/table.rs | |
parent | 0f2a239b967080ea041c21779f063ca1afcc3d2c (diff) |
Hide all raw pointers manipulation by users behind an opt-in feature flag
Diffstat (limited to 'rustables/src/table.rs')
-rw-r--r-- | rustables/src/table.rs | 10 |
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 |