use std::ffi::CStr;
use std::ffi::CString;
use std::ffi::OsString;
use std::os::unix::ffi::OsStrExt;
use std::os::unix::ffi::OsStringExt;
use std::path::Path;
use std::path::PathBuf;
#[inline]
pub(crate) fn path_to_cstr(path: &Path) -> CString {
CString::new(path.as_os_str().as_bytes()).unwrap()
}
#[inline]
pub(crate) fn cstr_to_path(path: &CStr) -> PathBuf {
PathBuf::from(OsString::from_vec(path.to_bytes().into()))
}
macro_rules! unsafe_wrapper {
($unsafe_block: block) => {{
let errcode: crate::error::LibErrorCode = unsafe { $unsafe_block };
match errcode {
btrfsutil_sys::btrfs_util_error_BTRFS_UTIL_OK => Result::Ok(()),
err => {
#[allow(unused_imports)]
use std::convert::TryFrom;
let err = crate::error::LibError::try_from(err).unwrap();
Result::Err(err.into())
}
}
}};
}