Maraiah/src/durandal/mod.rs

46 lines
833 B
Rust
Raw Normal View History

2018-12-13 01:06:57 -08:00
//! Library for various utilities.
2018-09-06 09:01:52 -07:00
#[allow(dead_code)]
pub mod bin;
2018-12-13 01:07:54 -08:00
pub mod chunk;
2018-09-09 15:13:50 -07:00
pub mod crc;
2018-12-11 00:08:23 -08:00
pub mod err;
2018-12-13 01:04:09 -08:00
pub mod fx32;
2018-09-06 09:01:52 -07:00
pub mod image;
2018-09-09 15:13:50 -07:00
pub mod machead;
pub mod text;
2018-09-06 09:01:52 -07:00
2018-12-13 01:06:57 -08:00
/// Creates an enumeration and function for converting a representation into
/// the enumeration type.
#[macro_export]
macro_rules! c_enum
{
(
$(#[$outer:meta])*
pub enum $E:ident: $T:ty
{
$($value:expr => $Enum:ident,)+
}
) => {
$(#[$outer])*
pub enum $E
{
$($Enum,)+
}
impl $E
{
pub fn from_repr(n: $T) -> ResultS<$E>
{
let t = match n {
$($value => $E::$Enum,)+
n => return Err(format_err!("invalid representation for {} (got {})", stringify!($E), n))
};
Ok(t)
}
}
};
}
2018-09-06 09:01:52 -07:00
// EOF