What is Nostr?
blinry /
npub1xh9…azuf
2025-02-15 11:23:41

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.
Author Public Key
npub1xh9fh6cs7c5zhhz330pz4s5kdwg44aq7xu33f6ylxtedkjj6g6ysvuazuf