mod accessors;
mod events;
mod incentive;
#[cfg(any(feature = "node-session-client", feature = "node-session-server"))]
pub mod session;
mod state;
mod status;
mod transport;
mod types;
pub use accessors::*;
pub use events::*;
pub use incentive::*;
#[cfg(feature = "node-session-client")]
pub use session::client::*;
#[cfg(feature = "node-session-server")]
pub use session::server::*;
pub use state::*;
pub use status::*;
pub use transport::*;
pub use types::*;
pub use crate::chain::{ChainInfo, ChannelId};
pub trait HoprNodeOperations {
fn status(&self) -> HoprState;
}
#[derive(Debug, Clone, Copy, thiserror::Error, strum::EnumTryAs)]
pub enum EitherErr<L: std::error::Error, R: std::error::Error> {
#[error(transparent)]
Left(L),
#[error(transparent)]
Right(R),
}
impl<L: std::error::Error, R: std::error::Error> EitherErr<L, R> {
#[inline]
pub fn left<E: Into<L>>(err: E) -> Self {
Self::Left(err.into())
}
#[inline]
pub fn right<E: Into<R>>(err: E) -> Self {
Self::Right(err.into())
}
}
pub trait EitherErrExt: std::error::Error {
#[inline]
fn into_left<R: std::error::Error>(self) -> EitherErr<Self, R>
where
Self: Sized,
{
EitherErr::Left(self)
}
#[inline]
fn into_right<L: std::error::Error>(self) -> EitherErr<L, Self>
where
Self: Sized,
{
EitherErr::Right(self)
}
}
impl<T: ?Sized + std::error::Error> EitherErrExt for T {}
pub type CompoundResult<T, E1, E2> = Result<T, EitherErr<E1, E2>>;