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
48
49
50
51
52
//! Components to directly interact with Nakadi
//!
//! This are used by the `Consumer` internally so metrics
//! and instrumentation within this module are
//! tailored for the `Consumer` but can be used
//! apart from it.
use std::error::Error as StdError;
use std::fmt;

use crate::api::{SubscriptionCommitApi, SubscriptionStreamApi};

pub mod committer;
pub mod connector;
pub mod streams;

pub trait StreamingEssentials:
    SubscriptionStreamApi + SubscriptionCommitApi + Send + Sync + 'static
{
}

impl<T> StreamingEssentials for T where
    T: SubscriptionStreamApi + SubscriptionCommitApi + Send + Sync + 'static
{
}

#[derive(Debug)]
pub struct IoError(String);

impl IoError {
    pub fn new<T: Into<String>>(s: T) -> Self {
        Self(s.into())
    }

    /// Keep private, needs improvement of IoError
    pub(crate) fn into_string(self) -> String {
        self.0
    }
}

impl fmt::Display for IoError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.0)?;

        Ok(())
    }
}

impl StdError for IoError {
    fn source(&self) -> Option<&(dyn StdError + 'static)> {
        None
    }
}