1- using System ;
2- using System . IO ;
1+ using System . Runtime . CompilerServices ;
32
43namespace EventStore . Plugins . Transforms ;
54
@@ -10,12 +9,26 @@ public class ChunkDataReadStream(Stream chunkFileStream) : Stream {
109 public sealed override bool CanSeek => true ;
1110 public sealed override bool CanWrite => false ;
1211 public sealed override void Write ( byte [ ] buffer , int offset , int count ) => throw new InvalidOperationException ( ) ;
12+ public override void Write ( ReadOnlySpan < byte > buffer ) => throw new InvalidOperationException ( ) ;
13+ public sealed override void WriteByte ( byte value ) => throw new InvalidOperationException ( ) ;
14+
1315 public sealed override void Flush ( ) => throw new InvalidOperationException ( ) ;
1416 public sealed override void SetLength ( long value ) => throw new InvalidOperationException ( ) ;
1517 public override long Length => throw new NotSupportedException ( ) ;
1618
17- // reads must always return exactly `count` bytes as we never read past the (flushed) writer checkpoint
18- public override int Read ( byte [ ] buffer , int offset , int count ) => ChunkFileStream . Read ( buffer , offset , count ) ;
19+ public sealed override int Read ( byte [ ] buffer , int offset , int count ) {
20+ ValidateBufferArguments ( buffer , offset , count ) ;
21+
22+ return Read ( buffer . AsSpan ( offset , count ) ) ;
23+ }
24+
25+ // reads must always return exactly `Span<byte>.Length` bytes as we never read past the (flushed) writer checkpoint
26+ public override int Read ( Span < byte > buffer ) => ChunkFileStream . Read ( buffer ) ;
27+
28+ public sealed override int ReadByte ( ) {
29+ Unsafe . SkipInit ( out byte value ) ;
30+ return Read ( new ( ref value ) ) is 1 ? value : - 1 ;
31+ }
1932
2033 // seeks need to support only `SeekOrigin.Begin`
2134 public override long Seek ( long offset , SeekOrigin origin ) {
0 commit comments