I want to have a clear, very well constrained bound on memory usage in MUD (text based online game). My design concept:
- Allocate a buffer after first getting data from a network socket.
- Parse the text as it arrives, but don't copy it out, keeping references to the buffer.
- Respond instantly to some network inputs that dont require any game state to process (negotiation etc).
- Read and respond to events that have showed up during each simulation tick (likely, only popping events at a certain frequency as determined by game logic).
- If more data shows up then can fit in the buffer, respond accordingly (dropping data or dropping the client as needed).
My problem is that I can't quite identify what, if any, existing data structure setup to use for this. My best guess is a simple u8 vec with a lock, and a tokio(?) networking stack that pushes parsed messages to a queue with indexes instead of references, but that seems horribly unergonomic and will require a lot of manually ensuring buffer bounds aren't broken. Has anyone solved anything like this before?