use crate::configuration::middleware_configuration::Configuration;
use crossbeam::{RecvError, RecvTimeoutError, TryRecvError};
use std::time::Duration;
pub trait TCB {
type SendCallReturn;
fn new(
local_id: usize,
local_port: usize,
peer_addresses: Vec<String>,
configuration: Configuration,
) -> Self;
fn send(&mut self, msg: Vec<u8>) -> Self::SendCallReturn;
fn end(&self);
fn recv(&mut self) -> Result<GenericReturn, RecvError>;
fn try_recv(&mut self) -> Result<GenericReturn, TryRecvError>;
fn recv_timeout(&mut self, duration: Duration) -> Result<GenericReturn, RecvTimeoutError>;
fn tcbstable(&mut self, id: usize, counter: usize);
}
pub enum GenericReturn {
Delivery(Vec<u8>, usize, usize),
Stable(usize, usize),
}