Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implement I/O-safe traits on types#1036

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
joshtriplett merged 6 commits intoasync-rs:mainfromforkgull:main
May 1, 2023
Merged

Conversation

notgull
Copy link
Contributor

@notgullnotgull commentedAug 11, 2022
edited
Loading

This PR adds a new feature,io_safety, which requires Rust 1.63 or higher. This trait implements theAsFd/AsHandle/AsSocket family of functions onasync-std's types. In addition, several types also implementFrom<OwnedFd/OwnedHandle/OwnedSocket> andInto<OwnedFd/OwnedHandle/OwnedSocket>.

See also:sunfishcode/io-lifetimes#38

runs-on:${{ matrix.os }}
strategy:
matrix:
os:[ubuntu-latest, windows-latest]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Doesn’t support MacOS?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The changes I wrote only impactcfg(unix) andcfg(windows), so I included a Unix platform (ubuntu-latest) and a Windows platform (windows-latest). If you would like me to also test on MacOS I can.

}
}

impl From<File> for OwnedFd {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should this beTryFrom?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I was mirroring the previous implementation forIntoRawFd for this type. If you would think that it would be better asTryFrom I will oblige.


impl From<TcpListener> for OwnedSocket {
fn from(listener: TcpListener) -> OwnedSocket {
listener.watcher.into_inner().unwrap().into()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should this beTryFrom?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I was mirroring theIntoRawSocket implementation for this type. Should this beTryFrom? If so, I can make it.

@yoshuawuyts
Copy link
Contributor

yoshuawuyts commentedAug 17, 2022
edited
Loading

Tagging in@sunfishcode who likely has thoughts on how we should approach this.

edit: I believe file and stdio types may actually be unsound to implement these traits on on windows?

@sunfishcode
Copy link
Contributor

edit: I believe file and stdio types may actually be unsound to implement these traits on on windows?

Are you referring to theOVERLAPPED issue in Windows? It's my understanding that that's nowfixed.

@sunfishcode
Copy link
Contributor

This change looks good to me. Overall, the intention forFrom<OwnedFd> andFrom<T> for OwnedFd impls is to mirror existingFromRawFd andIntoRawFd impls. In practice, the wayFromRawFd andIntoRawFd are used, users assume they have ownership-transfer semantics, so if there any issues with soundness with the new traits, they'd likely already present with the existing traits.

@sunfishcode
Copy link
Contributor

Also, it's currently the case that async-std doesn't currently callReadFile orNtReadFile itself; it currently usesstd::fs::File::read from withinspawn_blocking, so async-std wouldn't be doing anything that std itself isn't already doing.

@notgull
Copy link
ContributorAuthor

What is the current status of this PR?

@notgull
Copy link
ContributorAuthor

@yoshuawuyts Is there anything I can do to move this PR forwards?

@joshtriplett
Copy link
Contributor

Commented on a couple of minor issues. Happy to merge this with those fixed.

Co-authored-by: Josh Triplett <josh@joshtriplett.org>
@joshtriplettjoshtriplett merged commit7c95bce intoasync-rs:mainMay 1, 2023
@polarathenepolarathene mentioned this pull requestJul 23, 2024
@Keruspe
Copy link
Member

This is completely broken 😭
The feature is called io_safety and the cfg checks are done using io-safety as a feature name, so the code actually never got tested and doesn't even build.

joshtriplett reacted with confused emoji

@joshtriplett
Copy link
Contributor

@Keruspe Argh. :(

Would welcome PRs fixing this; that should happen before a new release.

@Keruspe
Copy link
Member

Should be fixed in master now, CI is green now

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

@joshtriplettjoshtriplettjoshtriplett left review comments

@Fishrock123Fishrock123Fishrock123 left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@notgull@yoshuawuyts@sunfishcode@joshtriplett@Keruspe@Fishrock123

[8]ページ先頭

©2009-2025 Movatter.jp