Added node comms

This commit is contained in:
Zachary Sunforge
2024-06-22 22:49:15 -07:00
parent a95cb64941
commit c5257dd827
7 changed files with 69 additions and 6 deletions

17
node/src/comms.rs Normal file
View File

@ -0,0 +1,17 @@
pub trait Sender {
async fn send(&mut self, msg: &[u8]) -> Result<(), Reset>;
}
pub trait Receiver {
async fn receive(&mut self, buffer: &mut [u8]) -> Result<(), Reset>;
}
//TODO: Replace with !
pub struct Never;
/// Communication errors indicates either:
/// Our connection was already disconnected, in which case we should reset and wait for new connection to made.
/// or
/// There was an unexpected, irrecoverable error in communication, in which case we don't want to enter a terminal error
/// safe mode, because there is no indication the actual control is broken, so all we can really do is reset the connection.
pub struct Reset;