dotnet/Nerdbank.Streams

add documentation for file read/write

Opened this issue · 1 comments

Hi, is there a way to use this library to read from file and write to file to boost performance? Can you help with an example - difficult to understand interface?

I was trying to use one of following libraries... it seems using IBufferReader

For serialize, interfaces as follows,

void Serialize<T>(IBufferWriter<byte> writer, T value);
void Serialize<T>(Stream stream, T value); 

For deserialize, interfaces as follows,

T Deserialize<T>(ReadOnlyMemory<byte> buffer);
T Deserialize<T>(Stream stream);
T Deserialize<T>(ReadOnlySequence<byte> byteSequence);

Context: we were trying to serialize/deserialize large files/.net objects for which IBuffer* handling is best.

This library isn't targeting making reading/writing to files on disk faster. But it does offer adapters between Stream and PipeReader/PipeWriter. Given a FileStream (which you carefully open with useAsync: true as a parameter!) then you could use UsePipe to to acquire a PipeReader/PipeWriter to write to that file. I would suggest though that you peruse Microsoft's own documentation for these types as to how to best use them, since this library didn't invent them--it merely adapts one to the other.