Warning
This post was published 67 days ago. The information described in this article may have changed.
I'm writing an IRC client library, and, in order to generalize handling of things like PINGs and CTCP messages, I've implemented a sans-IO "autoresponder" trait that can be attached to a client to make it automatically respond to select incoming messages whenever the "receive" method is called. In its simplest form, the receive method is intended to operate as follows:
Now, this method needs to handle being cancelled by a timeout or other mechanism, ideally by not losing any data and resuming any unfinished operations on the next call. By storing data on the client, I believe I've achieved cancellation safety, but I'd like someone else to check.
Links to the method and select associated code:
AutoResponder
traitAutoResponderSet
type, used by the client to operate on a collection of autoresponders at onceAny other code critiques are appreciated.
1 post - 1 participant
🏷️ rust_feed