1
- using System ;
2
- using System . IO ;
1
+ using System . Runtime . CompilerServices ;
3
2
4
3
namespace EventStore . Plugins . Transforms ;
5
4
@@ -10,12 +9,26 @@ public class ChunkDataReadStream(Stream chunkFileStream) : Stream {
10
9
public sealed override bool CanSeek => true ;
11
10
public sealed override bool CanWrite => false ;
12
11
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
+
13
15
public sealed override void Flush ( ) => throw new InvalidOperationException ( ) ;
14
16
public sealed override void SetLength ( long value ) => throw new InvalidOperationException ( ) ;
15
17
public override long Length => throw new NotSupportedException ( ) ;
16
18
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
+ }
19
32
20
33
// seeks need to support only `SeekOrigin.Begin`
21
34
public override long Seek ( long offset , SeekOrigin origin ) {
0 commit comments