make repo error types require std::error::Error

Summary: This gets us `Display` support as well.

Reviewed By: lukaspiatkowski

Differential Revision: D5734383

fbshipit-source-id: 1485cf80bb310cdd282b4546bed56c60082be8ec
This commit is contained in:
Siddharth Agarwal 2017-08-31 13:36:49 -07:00 committed by Facebook Github Bot
parent 8202a344b4
commit c1a30e25c9
5 changed files with 30 additions and 18 deletions

View File

@ -31,6 +31,7 @@ extern crate serde;
extern crate bincode; extern crate bincode;
use std::error;
use std::io; use std::io;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::sync::Arc; use std::sync::Arc;
@ -145,7 +146,7 @@ fn copy_manifest_entry<E>(
) -> BoxFuture<(), Error> ) -> BoxFuture<(), Error>
where where
Error: From<E>, Error: From<E>,
E: Send + 'static, E: error::Error + Send + 'static,
{ {
let hash = *entry.get_hash(); let hash = *entry.get_hash();

View File

@ -38,6 +38,7 @@ extern crate serde;
extern crate serde_json; extern crate serde_json;
use std::collections::HashMap; use std::collections::HashMap;
use std::error;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::str::FromStr; use std::str::FromStr;
use std::string::ToString; use std::string::ToString;
@ -140,7 +141,7 @@ struct TreeMetadata {
impl TreeMetadata { impl TreeMetadata {
fn new<E>(size: Option<usize>, entry: Box<mercurial_types::Entry<Error = E>>) -> TreeMetadata fn new<E>(size: Option<usize>, entry: Box<mercurial_types::Entry<Error = E>>) -> TreeMetadata
where where
E: Send + 'static, E: error::Error + Send + 'static,
{ {
TreeMetadata { TreeMetadata {
hash: entry.get_hash().clone(), hash: entry.get_hash().clone(),

View File

@ -4,6 +4,7 @@
// This software may be used and distributed according to the terms of the // This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version. // GNU General Public License version 2 or any later version.
use std::error;
use std::fmt::{self, Display}; use std::fmt::{self, Display};
use std::marker::PhantomData; use std::marker::PhantomData;
@ -17,7 +18,7 @@ use path::Path;
/// Interface for a manifest /// Interface for a manifest
pub trait Manifest: Send + 'static { pub trait Manifest: Send + 'static {
type Error: Send + 'static; type Error: error::Error + Send + 'static;
fn lookup( fn lookup(
&self, &self,
@ -52,7 +53,7 @@ where
impl<M, E> BoxManifest<M, E> impl<M, E> BoxManifest<M, E>
where where
M: Manifest + Sync + Send + 'static, M: Manifest + Sync + Send + 'static,
E: Send + 'static, E: error::Error + Send + 'static,
{ {
pub fn new(manifest: M) -> Box<Manifest<Error = E> + Sync> pub fn new(manifest: M) -> Box<Manifest<Error = E> + Sync>
where where
@ -78,7 +79,7 @@ where
impl<M, E> Manifest for BoxManifest<M, E> impl<M, E> Manifest for BoxManifest<M, E>
where where
M: Manifest + Sync + Send + 'static, M: Manifest + Sync + Send + 'static,
E: Send + 'static, E: error::Error + Send + 'static,
{ {
type Error = E; type Error = E;
@ -106,7 +107,10 @@ where
} }
} }
impl<E: Send + 'static> Manifest for Box<Manifest<Error = E> + Sync> { impl<E> Manifest for Box<Manifest<Error = E> + Sync>
where
E: error::Error + Send + 'static,
{
type Error = E; type Error = E;
fn lookup( fn lookup(
@ -138,11 +142,11 @@ pub enum Content<E> {
impl<E> Content<E> impl<E> Content<E>
where where
E: Send + 'static, E: error::Error + Send + 'static,
{ {
fn map_err<ME>(self, cvterr: fn(E) -> ME) -> Content<ME> fn map_err<ME>(self, cvterr: fn(E) -> ME) -> Content<ME>
where where
ME: Send + 'static, ME: error::Error + Send + 'static,
{ {
match self { match self {
Content::Tree(m) => Content::Tree(BoxManifest::new_with_cvterr(m, cvterr)), Content::Tree(m) => Content::Tree(BoxManifest::new_with_cvterr(m, cvterr)),
@ -154,7 +158,7 @@ where
} }
pub trait Entry: Send + 'static { pub trait Entry: Send + 'static {
type Error: Send + 'static; type Error: error::Error + Send + 'static;
fn get_type(&self) -> Type; fn get_type(&self) -> Type;
fn get_parents(&self) -> BoxFuture<Parents, Self::Error>; fn get_parents(&self) -> BoxFuture<Parents, Self::Error>;
@ -191,7 +195,7 @@ where
impl<Ent, E> BoxEntry<Ent, E> impl<Ent, E> BoxEntry<Ent, E>
where where
Ent: Entry + Sync + Send + 'static, Ent: Entry + Sync + Send + 'static,
E: Send + 'static, E: error::Error + Send + 'static,
{ {
pub fn new(entry: Ent) -> Box<Entry<Error = E> + Sync> pub fn new(entry: Ent) -> Box<Entry<Error = E> + Sync>
where where
@ -215,7 +219,7 @@ where
impl<Ent, E> Entry for BoxEntry<Ent, E> impl<Ent, E> Entry for BoxEntry<Ent, E>
where where
Ent: Entry + Sync + Send + 'static, Ent: Entry + Sync + Send + 'static,
E: Send + 'static, E: error::Error + Send + 'static,
{ {
type Error = E; type Error = E;
@ -253,7 +257,10 @@ where
} }
} }
impl<E: Send + 'static> Entry for Box<Entry<Error = E> + Sync> { impl<E> Entry for Box<Entry<Error = E> + Sync>
where
E: error::Error + Send + 'static,
{
type Error = E; type Error = E;
fn get_type(&self) -> Type { fn get_type(&self) -> Type {

View File

@ -4,6 +4,8 @@
// This software may be used and distributed according to the terms of the // This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version. // GNU General Public License version 2 or any later version.
use std::error;
use futures::{Future, Stream}; use futures::{Future, Stream};
/// A general source control Node /// A general source control Node
@ -17,7 +19,7 @@ use futures::{Future, Stream};
/// code. /// code.
pub trait Node: Sized { pub trait Node: Sized {
type Content; type Content;
type Error; type Error: error::Error;
type GetParents: Stream<Item = Self, Error = Self::Error>; type GetParents: Stream<Item = Self, Error = Self::Error>;
type GetContent: Future<Item = Self::Content, Error = Self::Error>; type GetContent: Future<Item = Self::Content, Error = Self::Error>;

View File

@ -4,6 +4,7 @@
// This software may be used and distributed according to the terms of the // This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version. // GNU General Public License version 2 or any later version.
use std::error;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::sync::Arc; use std::sync::Arc;
@ -25,7 +26,7 @@ pub type BoxedBookmarks<E> = Box<
>; >;
pub trait Repo: 'static { pub trait Repo: 'static {
type Error: Send + 'static; type Error: error::Error + Send + 'static;
/// Return a stream of all changeset ids /// Return a stream of all changeset ids
/// ///
@ -73,7 +74,7 @@ where
impl<R, E> BoxRepo<R, E> impl<R, E> BoxRepo<R, E>
where where
R: Repo + Sync + Send, R: Repo + Sync + Send,
E: Send + 'static, E: error::Error + Send + 'static,
{ {
pub fn new(repo: R) -> Box<Repo<Error = E> + Sync + Send> pub fn new(repo: R) -> Box<Repo<Error = E> + Sync + Send>
where where
@ -99,7 +100,7 @@ where
impl<R, E> Repo for BoxRepo<R, E> impl<R, E> Repo for BoxRepo<R, E>
where where
R: Repo + Sync + Send + 'static, R: Repo + Sync + Send + 'static,
E: Send + 'static, E: error::Error + Send + 'static,
{ {
type Error = E; type Error = E;
@ -149,7 +150,7 @@ where
impl<RE> Repo for Box<Repo<Error = RE>> impl<RE> Repo for Box<Repo<Error = RE>>
where where
RE: Send + 'static, RE: error::Error + Send + 'static,
{ {
type Error = RE; type Error = RE;
@ -183,7 +184,7 @@ where
impl<RE> Repo for Arc<Repo<Error = RE>> impl<RE> Repo for Arc<Repo<Error = RE>>
where where
RE: Send + 'static, RE: error::Error + Send + 'static,
{ {
type Error = RE; type Error = RE;