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
29
30
31
32
33
34
35
36
37
38
39
mod nonce;
pub use self::nonce::{ GenNonce, RngCounter, NonceCounter };
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<T> TryFrom<T> for $name where T: AsRef<[u8]> {
type Err = io::Error;
fn try_from($input_from: T) -> io::Result<Self> {
let $input_from = $input_from.as_ref();
$from
}
}
impl From<$name> for $output {
fn from($input_into: $name) -> $output $into
}
}
}
macro_rules! err {
( $err:ident, $msg:expr ) => {
Err(::std::io::Error::new(
::std::io::ErrorKind::$err,
$msg
))
}
}