Skip to content

Commit

Permalink
add sync type bounds on errors
Browse files Browse the repository at this point in the history
  • Loading branch information
benmaddison committed Aug 24, 2021
1 parent 4534920 commit c6714c3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl Connection {
pub fn pipeline_from_initial<T, F, I>(&mut self, initial: Query, f: F) -> QueryResult<Pipeline>
where
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static,
T::Err: Error + Send + Sync + 'static,
F: Fn(QueryResult<ResponseItem<T>>) -> Option<I>,
I: IntoIterator<Item = Query>,
{
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub enum QueryError {
/// An unrecoverable error during parsing.
ParseFailure,
/// An error occured while parsing a response item.
ItemParse(Box<dyn Error + Send>),
ItemParse(Box<dyn Error + Send + Sync>),
}

impl fmt::Display for QueryError {
Expand Down
34 changes: 17 additions & 17 deletions src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl<'a> Pipeline<'a> {
where
'a: 'b,
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static,
T::Err: Error + Send + Sync + 'static,
F: Fn(QueryResult<ResponseItem<T>>) -> Option<I>,
I: IntoIterator<Item = Query>,
{
Expand Down Expand Up @@ -121,7 +121,7 @@ impl<'a> Pipeline<'a> {
pub fn pop<'b, T>(&'b mut self) -> Option<QueryResult<Response<'a, 'b, T>>>
where
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static,
T::Err: Error + Send + Sync + 'static,
{
self.pop_wrapped()
.map(|wrapped| wrapped.map_err(|err| err.take_inner()))
Expand All @@ -133,7 +133,7 @@ impl<'a> Pipeline<'a> {
where
'a: 'b,
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static,
T::Err: Error + Send + Sync + 'static,
{
self.queue.pop_front().map(move |query| {
let expect = loop {
Expand Down Expand Up @@ -209,7 +209,7 @@ impl<'a> Pipeline<'a> {
where
'a: 'b,
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static,
T::Err: Error + Send + Sync + 'static,
{
Responses {
pipeline: Some(self),
Expand Down Expand Up @@ -299,7 +299,7 @@ pub struct Responses<'a, 'b, T>
where
'a: 'b,
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static,
T::Err: Error + Send + Sync + 'static,
{
pipeline: Option<&'b mut Pipeline<'a>>,
current_reponse: Option<Response<'a, 'b, T>>,
Expand All @@ -308,7 +308,7 @@ where
impl<T> Responses<'_, '_, T>
where
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static,
T::Err: Error + Send + Sync + 'static,
{
fn consume(&mut self) {
for item in self {
Expand All @@ -321,7 +321,7 @@ impl<'a, 'b, T> Iterator for Responses<'a, 'b, T>
where
'a: 'b,
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static,
T::Err: Error + Send + Sync + 'static,
{
type Item = QueryResult<ResponseItem<T>>;
fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -367,7 +367,7 @@ pub struct Response<'a, 'b, T>
where
'a: 'b,
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static,
T::Err: Error + Send + Sync + 'static,
{
query: Query,
pipeline: Option<&'b mut Pipeline<'a>>,
Expand All @@ -380,7 +380,7 @@ impl<'a, 'b, T> Response<'a, 'b, T>
where
'a: 'b,
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static,
T::Err: Error + Send + Sync + 'static,
{
pub(crate) fn new(query: Query, pipeline: &'b mut Pipeline<'a>, expect: usize) -> Self {
Self {
Expand Down Expand Up @@ -455,7 +455,7 @@ where
impl<T> Drop for Response<'_, '_, T>
where
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static,
T::Err: Error + Send + Sync + 'static,
{
fn drop(&mut self) {
self.consume();
Expand All @@ -465,7 +465,7 @@ where
impl<T> Iterator for Response<'_, '_, T>
where
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static,
T::Err: Error + Send + Sync + 'static,
{
type Item = QueryResult<ResponseItem<T>>;

Expand All @@ -480,7 +480,7 @@ where
enum ItemOrYield<'a, 'b, T>
where
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static,
T::Err: Error + Send + Sync + 'static,
{
Item(QueryResult<ResponseItem<T>>),
Yield(&'b mut Pipeline<'a>),
Expand All @@ -494,12 +494,12 @@ where
pub struct ResponseItem<T>(ResponseContent<T>, Query)
where
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static;
T::Err: Error + Send + Sync + 'static;

impl<T> ResponseItem<T>
where
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static,
T::Err: Error + Send + Sync + 'static,
{
/// Borrow the content of [`ResponseItem`].
pub fn content(&self) -> &T {
Expand All @@ -521,12 +521,12 @@ where
pub(crate) struct ResponseContent<T>(T)
where
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static;
T::Err: Error + Send + Sync + 'static;

impl<T> ResponseContent<T>
where
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static,
T::Err: Error + Send + Sync + 'static,
{
fn content(&self) -> &T {
&self.0
Expand All @@ -540,7 +540,7 @@ where
impl<T> FromStr for ResponseContent<T>
where
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static,
T::Err: Error + Send + Sync + 'static,
{
type Err = QueryError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Expand Down
2 changes: 1 addition & 1 deletion src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Query {
pub(crate) fn parse_item<T>(&self, input: &[u8]) -> QueryResult<(usize, ResponseContent<T>)>
where
T: FromStr + fmt::Debug,
T::Err: Error + Send + 'static,
T::Err: Error + Send + Sync + 'static,
{
let (_, (consumed, item)) = match self {
_ if !self.expect_data() => parse::noop(input)?,
Expand Down

0 comments on commit c6714c3

Please sign in to comment.