@@ -129,12 +129,12 @@ private final class FileChunkProducer: NIOAsyncSequenceProducerDelegate, Sendabl
129
129
let length : Int64
130
130
131
131
init ( range: FileChunks . ChunkRange , handle: SystemFileHandle , length: Int64 ) {
132
-
133
- let state : ProducerState = switch range {
132
+ let state : ProducerState
133
+ switch range {
134
134
case . entireFile:
135
- . init( handle: handle, range: nil )
135
+ state = . init( handle: handle, range: nil )
136
136
case . partial( let partialRange) :
137
- . init( handle: handle, range: partialRange)
137
+ state = . init( handle: handle, range: partialRange)
138
138
}
139
139
140
140
self . state = NIOLockedValueBox ( state)
@@ -357,13 +357,13 @@ private struct ProducerState: Sendable {
357
357
mutating func didReadBytes( _ count: Int ) {
358
358
switch self . state {
359
359
case var . producing( state) :
360
- if state. updateRange ( count : count) {
360
+ if state. didReadBytes ( count) {
361
361
self . state = . done( emptyRange: false )
362
362
} else {
363
363
self . state = . producing( state)
364
364
}
365
365
case var . pausedProducing( state) :
366
- if state. updateRange ( count : count) {
366
+ if state. didReadBytes ( count) {
367
367
self . state = . done( emptyRange: false )
368
368
} else {
369
369
self . state = . pausedProducing( state)
@@ -399,7 +399,10 @@ private struct ProducerState: Sendable {
399
399
400
400
@available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
401
401
extension ProducerState . Producing {
402
- mutating func updateRange( count: Int ) -> Bool {
402
+ /// Updates the range (the offsets to read from and up to) to reflect the number of bytes which have been read.
403
+ /// - Parameter count: The number of bytes which have been read.
404
+ /// - Returns: Returns `True` if there are no remaining bytes to read, `False` otherwise.
405
+ mutating func didReadBytes( _ count: Int ) -> Bool {
403
406
guard let currentRange = self . range else {
404
407
// if we read 0 bytes we are done
405
408
return count == 0
0 commit comments