Skip to content

[NIOFileSystem] Provide an API to specify allowing unlimited sized reads#2914

Merged
glbrntt merged 3 commits into
apple:mainfrom
clintonpi:provide-api-to-specify-allowing-unlimited-sized-reads
Oct 11, 2024
Merged

[NIOFileSystem] Provide an API to specify allowing unlimited sized reads#2914
glbrntt merged 3 commits into
apple:mainfrom
clintonpi:provide-api-to-specify-allowing-unlimited-sized-reads

Conversation

@clintonpi
Copy link
Copy Markdown
Contributor

Motivation:

As described in issue #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.

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.
Copy link
Copy Markdown
Contributor

@glbrntt glbrntt left a 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

Comment on lines +338 to +341
var maximumSizeAllowed = maximumSizeAllowed
if maximumSizeAllowed == .unlimited {
maximumSizeAllowed = .byteBufferCapacity
}
Copy link
Copy Markdown
Contributor

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

@glbrntt glbrntt added the 🆕 semver/minor Adds new public API. label Oct 11, 2024
@clintonpi clintonpi requested a review from glbrntt October 11, 2024 08:30
@glbrntt glbrntt enabled auto-merge (squash) October 11, 2024 08:31
@glbrntt glbrntt merged commit 17ebfcd into apple:main Oct 11, 2024
@clintonpi clintonpi deleted the provide-api-to-specify-allowing-unlimited-sized-reads branch October 11, 2024 09:26
}
}

func XCTAssertNoThrowAsync<T>(
Copy link
Copy Markdown
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants