razor_libzfs_sys/
lib.rs

1#![allow(non_camel_case_types)]
2#![allow(deref_nullptr)]
3
4use razor_libnvpair::*;
5
6include!(concat!(env!("OUT_DIR"), "/zfs.rs"));
7
8impl zfs_type_t {
9    /// Returns true if the type is a filesystem.
10    ///
11    pub fn is_filesystem(&self) -> bool {
12        *self & zfs_type_t::ZFS_TYPE_FILESYSTEM != zfs_type_t(0)
13    }
14
15    /// Returns true if the type is a snapshot.
16    ///
17    pub fn is_snapshot(&self) -> bool {
18        *self & zfs_type_t::ZFS_TYPE_SNAPSHOT != zfs_type_t(0)
19    }
20
21    /// Returns true if the type is a volume.
22    ///
23    pub fn is_volume(&self) -> bool {
24        *self & zfs_type_t::ZFS_TYPE_VOLUME != zfs_type_t(0)
25    }
26
27    /// Returns true if the type is a bookmark.
28    ///
29    pub fn is_bookmark(&self) -> bool {
30        *self & zfs_type_t::ZFS_TYPE_BOOKMARK != zfs_type_t(0)
31    }
32
33    /// Returns true if the type is a pool.
34    ///
35    pub fn is_pool(&self) -> bool {
36        *self & zfs_type_t::ZFS_TYPE_POOL != zfs_type_t(0)
37    }
38
39    pub fn contains(&self, other: zfs_type_t) -> bool {
40        *self & other != zfs_type_t(0)
41    }
42}
43
44impl From<zfs_prop_t> for ::std::borrow::Cow<'static, str> {
45    fn from(property: zfs_prop_t) -> Self {
46        unsafe {
47            let cstr = zfs_prop_to_name(property);
48            ::std::ffi::CStr::from_ptr(cstr).to_string_lossy()
49        }
50    }
51}