diff options
author | Simon THOBY <git@nightmared.fr> | 2021-11-05 06:23:45 +0000 |
---|---|---|
committer | Simon THOBY <git@nightmared.fr> | 2021-11-05 06:23:45 +0000 |
commit | 46b22d88c36863851e4b27efa767d28c8aeecfe0 (patch) | |
tree | ab1a638de7587e7b73fe64093428218e1c545004 /rustables/src/set.rs | |
parent | 3f61ea42bd291c208d07006d8019c25d588f9183 (diff) | |
parent | 1bec5a5c30541e47e9c7cff839ac0e7dd3fb6215 (diff) |
Merge branch 'manipulate-exprs' into 'master'
Add functions to iterate over the expressions of existing rules
See merge request rustwall/rustables!3
Diffstat (limited to 'rustables/src/set.rs')
-rw-r--r-- | rustables/src/set.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/rustables/src/set.rs b/rustables/src/set.rs index d8c84d6..aef74db 100644 --- a/rustables/src/set.rs +++ b/rustables/src/set.rs @@ -27,9 +27,9 @@ macro_rules! nft_set { } pub struct Set<'a, K> { - set: *mut sys::nftnl_set, - table: &'a Table, - family: ProtoFamily, + pub(crate) set: *mut sys::nftnl_set, + pub(crate) table: &'a Table, + pub(crate) family: ProtoFamily, _marker: ::std::marker::PhantomData<K>, } @@ -130,10 +130,14 @@ impl<'a, K> Set<'a, K> { } } - pub fn get_name(&self) -> &CStr { + pub fn get_name(&self) -> Option<&CStr> { unsafe { let ptr = sys::nftnl_set_get_str(self.set, sys::NFTNL_SET_NAME as u16); - CStr::from_ptr(ptr) + if !ptr.is_null() { + Some(CStr::from_ptr(ptr)) + } else { + None + } } } |