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
40
41
42
43
44
45
46
47
use log::{trace};
use std::{
io,
io::{
prelude::*,
}
};
mod nng_channel;
pub use crate::nng_channel::*;
mod nng_protocol;
pub use crate::nng_protocol::*;
enum NngThriftError {
Nng(runng::NngFail),
Thrift(thrift::Error),
}
type NngThriftResult<T> = Result<T, NngThriftError>;
fn result_wrapper<T>(result: runng::NngResult<T>) -> NngThriftResult<T> {
match result {
Ok(result) => Ok(result),
Err(result) => Err(NngThriftError::Nng(result)),
}
}
impl From<NngThriftError> for thrift::Error {
fn from(err: NngThriftError) -> thrift::Error {
match err {
NngThriftError::Nng(err) => {
let err: io::Error = From::from(err);
thrift::Error::from(err)
}
NngThriftError::Thrift(err) => err,
}
}
}