1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//! Sarkara utils.

#[macro_use] mod rand_macro;
mod nonce;

pub use self::nonce::{ Nonce, RngCounter };


macro_rules! new_type {
    (
        $(#[$note:meta])*
        pub struct $name:ident ( pub $typ:ty ) ;
        from: ( $input_from:ident ) $from:block,
        into: ( $input_into:ident ) -> $output:ty $into:block
    ) => {
        $(#[$note])*
        pub struct $name(pub $typ);

        impl<'a> TryFrom<&'a [u8]> for $name {
            type Err = io::Error;
            fn try_from($input_from: &[u8]) -> io::Result<Self> $from
        }

        impl From<$name> for $output {
            fn from($input_into: $name) -> $output $into
        }
    }
}