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
//! Implements Raiden protocol messages and matrix network integration to exchange messages between
//! nodes over the wire.
use matrix_sdk::HttpError;
use raiden_network_messages::messages::OutgoingMessage;
use raiden_primitives::types::QueueIdentifier;
use thiserror::Error;

pub mod config;
pub mod matrix;
#[cfg(test)]
mod tests;
pub mod types;

/// The transport error type.
#[derive(Error, Debug)]
pub enum TransportError {
	#[error("Could not initialize transport: `{0}`")]
	Init(String),
	#[error("Could to sync events: `{0}`")]
	Sync(String),
	#[error("Could to send messages: `{0}`")]
	Send(HttpError),
	#[error("Error: `{0}`")]
	Other(String),
}

#[async_trait::async_trait]
pub trait Transport {
	async fn init(&self) -> Result<(), TransportError>;
	async fn send(
		&self,
		queue_identifier: QueueIdentifier,
		message: OutgoingMessage,
	) -> Result<(), TransportError>;
	async fn process(mut self);
}