libbtrfs 0.0.20

Rust library for working with the btrfs filesystem
Documentation
#![allow(unused_macros)]

macro_rules! error {
    ( $kind:ident $(;)? ) => {
        return Err(::std::io::Error::from(::std::io::ErrorKind::$kind))
    };
    ( $kind:ident ; $($msg: expr),+ ) => {
        return Err(::std::io::Error::new(::std::io::ErrorKind::$kind, format!( $($msg),+ )))
    };
    ( $($msg: expr),+ ) => {
        return Err(std::io::Error::new(std::io::ErrorKind::Other, format!( $($msg),+ )))
    };
}

// for implmeting iterator next trait
macro_rules! try_or_some_err {
    ($expr:expr $(,)?) => {
        match $expr {
            ::std::result::Result::Ok(val) => val,
            ::std::result::Result::Err(err) => {
                return Some(::std::result::Result::Err(::std::convert::From::from(err)));
            }
        }
    };
}

macro_rules! syscall {
    ($name:ident($( $args:expr ),*)) => {
        {
            #[cfg(not(feature = "use-syscalls"))]
            match ::libc::$name($( $args ),*) {
                -1 => Err(::std::io::Error::last_os_error()),
                res => Ok(res)
            }

            #[cfg(feature = "use-syscalls")]
            match $crate::util::use_syscalls::def!($name($( $args ),*)) {
                Err(e) => Err(::std::io::Error::from_raw_os_error(e.into_raw())),
                Ok(res) => Ok(res as ::libc::c_int),
            }
        }
    };

    (unsafe { $name:ident( $( $args:expr ),* ) }) => {
        unsafe { syscall!($name($( $args ),*)) }
    };
}