Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern crate futures;
- extern crate futures_cpupool;
- extern crate grpc;
- extern crate protobuf;
- extern crate tokio_timer;
- pub mod client;
- pub mod client_grpc;
- use futures::Future;
- use futures::MapErr;
- use std::error::Error;
- use std::fmt::Result as FmtResult;
- use std::fmt::Display;
- use std::fmt::Formatter;
- use grpc::error::GrpcError;
- use grpc::futures_grpc::GrpcFutureSend;
- use tokio_timer::TimeoutError;
- use client::TestResponse;
- #[derive(Debug)]
- pub enum TestError {
- Grpc(GrpcError),
- Timeout,
- }
- impl Error for TestError {
- fn description(&self) -> &str {
- match *self {
- TestError::Grpc(ref grpc_error) => grpc_error.description(),
- TestError::Timeout => "operation timed out",
- }
- }
- fn cause(&self) -> Option<&Error> {
- match *self {
- TestError::Grpc(ref grpc_error) => grpc_error.cause(),
- TestError::Timeout => None,
- }
- }
- }
- impl Display for TestError {
- fn fmt(&self, f: &mut Formatter) -> FmtResult {
- match *self {
- TestError::Grpc(ref grpc_error) => grpc_error.fmt(f),
- TestError::Timeout => write!(f, "operation timed out"),
- }
- }
- }
- impl<F> From<TimeoutError<MapErr<Box<Future<Error=GrpcError, Item=TestResponse> + Send>, F>>> for TestError
- where F: FnOnce (GrpcError) -> TestError {
- fn from(err: TimeoutError<MapErr<Box<Future<Error=GrpcError, Item=TestResponse> + Send>, F>>) -> Self {
- TestError::Timeout
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement