Skip to content
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

Update the API for I/O safety #66

Merged
merged 3 commits into from
Sep 18, 2024
Merged

Update the API for I/O safety #66

merged 3 commits into from
Sep 18, 2024

Conversation

sunfishcode
Copy link
Contributor

Add new terminal_size_of fuctions which use the AsFd and AsHandle traits to accept file descriptors (on Unix) and handles (on Windows).

Deprecate the existing terminal_size_using_* functions which take raw file descriptors or handles without being unsafe.

And update the get_size example to use the new terminal_size_of functions. The example can now be much simpler because the main API is now the same between Windows and Unix in common cases.

Add new `terminal_size_of` fuctions which use the `AsFd` and `AsHandle`
traits to accept file descriptors (on Unix) and handles (on Windows).

Deprecate the existing `terminal_size_using_*` functions which take raw
file descriptors or handles without being `unsafe`.

And update the `get_size` example to use the new `terminal_size_of`
functions. The example can now be much simpler because the main API is
now the same between Windows and Unix in common cases.
@eminence
Copy link
Owner

Thanks! I'm sure the code is fine, but I want to take a moment to make sure I understand it. Target for merge and release is sometime next weekend.

src/unix.rs Outdated Show resolved Hide resolved
@eminence eminence merged commit 5307747 into eminence:master Sep 18, 2024
17 checks passed
@eminence
Copy link
Owner

Thanks again for this PR (and for all your work on pushing the I/O safety stuff)

@sunfishcode sunfishcode deleted the main branch September 18, 2024 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants