Protocol automata and stream visitor
See commits. This allows to replace some boilerplate with library code. Reads much better now. This will be used in GitLab access module I'm working on for gitlab-org/gitlab#289958 (closed).
Video overview https://youtu.be/us7F8LtGBsY
Edited by Mikhail Mazurskiy