What is the design behind System.IO.Pipelines #53693
-
Stream is a layered API, if I want apply some pre/post processing to a stream, I just wrap the existing stream in a stream that does the operations I want. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You should do the same. Decorating an existing PipeReader/PipeWriter is the most efficient way to expose these pipelines.
This is also possible and easier but less efficient. Ideally you would only introduce your own buffer when the user decides to buffer their own data.
There's a higher level API here I've been experimenting with https://github.com/davidfowl/BedrockFramework/tree/main/src/Bedrock.Framework/Protocols. There are also lots of decorator PipeReader/PipeWriter in http://github.com/dotnet/aspnetcore/
Most of the core types are optimized for wrapping a Stream and adding some buffering logic on top. This is why we haven't shipped any other native PipeReader/PipeWriter out of the box. |
Beta Was this translation helpful? Give feedback.
You should do the same. Decorating an existing PipeReader/PipeWriter is the most efficient way to expose these pipelines.
This is also possible and easier but less efficient. Ideally you would only introduce your own buffer when the user decides to buffer their own data.
There's a higher lev…