nox-core 0.1.0

Shared protocol types for the NOX mixnet (events, traits, models, fragmentation)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::models::payloads::RelayerPayload;
use async_trait::async_trait;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum ServiceError {
    #[error("Processing failed: {0}")]
    ProcessingFailed(String),
    #[error("Payload ignored")]
    Ignored,
}

#[async_trait]
pub trait ServiceHandler: Send + Sync {
    fn name(&self) -> &'static str;
    async fn handle(&self, packet_id: &str, payload: &RelayerPayload) -> Result<(), ServiceError>;
}