using System; using System.Threading; using System.Threading.Tasks; using FrostFS.Object; using Grpc.Core; namespace FrostFS.SDK.ClientV2; public sealed class RangeReader(AsyncServerStreamingCall call) : IObjectReader { private bool disposed; public AsyncServerStreamingCall Call { get; private set; } = call; public async ValueTask?> ReadChunk(CancellationToken cancellationToken = default) { if (!await Call.ResponseStream.MoveNext(cancellationToken).ConfigureAwait(false)) return null; var response = Call.ResponseStream.Current; Verifier.CheckResponse(response); return response.Body.Chunk.Memory; } public void Dispose() { if (!disposed) { Call?.Dispose(); GC.SuppressFinalize(this); disposed = true; } } }