Seems pretty similar to the design of OKIO in java [1]. With pretty similar goals ultimately. Here's a presentation on the internal details and design decisions. [2]
[1] https://github.com/square/okio
[2] https://www.youtube.com/watch?v=Du7YXPAV1M8