blinry on Nostr: Pondering about a software architecture/#Rust problem… Consider this interface for ...
Pondering about a software architecture/#Rust problem…
Consider this interface for a "sans-IO" component:
trait Daemon {
fn connect(&mut self, id: usize);
fn input(&mut self, id: usize, data: Vec<u8>);
fn disconnect(&mut self, id: usize);
fn poll_output(&mut self) -> (usize, Vec<u8>);
}
A "runtime" will call the first three methods to tell the daemon about new/ending connections, and data. It will poll the last one to check if the daemon wants to send data to one of the connections.
Consider this interface for a "sans-IO" component:
trait Daemon {
fn connect(&mut self, id: usize);
fn input(&mut self, id: usize, data: Vec<u8>);
fn disconnect(&mut self, id: usize);
fn poll_output(&mut self) -> (usize, Vec<u8>);
}
A "runtime" will call the first three methods to tell the daemon about new/ending connections, and data. It will poll the last one to check if the daemon wants to send data to one of the connections.