-
Notifications
You must be signed in to change notification settings - Fork 652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NIOFileSystem] Provide an API to specify allowing unlimited sized reads #2914
[NIOFileSystem] Provide an API to specify allowing unlimited sized reads #2914
Conversation
Motivation: As described in issue [apple#2877](apple#2877), there is no API available to specify allowing a read of unlimited size. Modifications: - Add a new `public static` property, `unlimited`, to `ByteCount` representing an unlimited amount of bytes. - Adapt `ReadableFileHandleProtocol.readToEnd(fromAbsoluteOffset:maximumSizeAllowed:)` to work with `maximumSizeAllowed` being `ByteCount.unlimited`. Result: An API to specify allowing a read of an unlimited size will be available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit but looks great otherwise
var maximumSizeAllowed = maximumSizeAllowed | ||
if maximumSizeAllowed == .unlimited { | ||
maximumSizeAllowed = .byteBufferCapacity | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do this in a one line to keep maximumSizeAllowed
constant:
let maximumSizeAllowed = maximumSizeAllowed == .unlimited ? .byteBufferCapacity : maximumSizeAllowed
@@ -69,4 +69,16 @@ func XCTAssertThrowsFileSystemErrorAsync<R>( | |||
} | |||
} | |||
} | |||
|
|||
func XCTAssertNoThrowAsync<T>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shouldn't squat on XCTest's XCT*
name space, you can make it NIOAssertNoThrowAsync
or smth
Motivation:
As described in issue #2877, there is no API available to specify allowing a read of unlimited size.
Modifications:
public static
property,unlimited
, toByteCount
representing an unlimited amount of bytes.ReadableFileHandleProtocol.readToEnd(fromAbsoluteOffset:maximumSizeAllowed:)
to work withmaximumSizeAllowed
beingByteCount.unlimited
.Result:
An API to specify allowing a read of an unlimited size will be available.