rust-lang / rust-lang/rfcs

RawOs marker traits

Open
#1,256 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

T-libs
Dominant language
Markdown
Stars
6.6k
Forks
1.7k
Avg merge
16h 14m
Merged PRs (30d)
1

Description

Currently, the {As,From}Raw{Fd,Handle} traits don't provide any information about how the file descriptors might safely be used (and don't even guarantee that the file descriptor is valid). Therefore, I would like to propose traits like:

/// Can safely write
unsafe trait RawOsWrite {}
/// Can safely read
unsafe trait RawOsRead {}
/// Can safely seek
unsafe trait RawOsSeek {}
/// Can safely access metadata. May not be necessary (always safe)?
unsafe trait RawOsMeta {}

These traits, when implemented on a type implementing one of the AsRaw/IntoRaw traits, would guarantee that the specified operation can be performed on the file descriptor/handle without causing memory unsafety. This doesn't mean that the operation will succeed, just that it won't be unsafe.

Unresolved: For AsRaw*, it's unclear when this guarantee expires. Personally, I'd like to say that the guarantee holds until the file descriptor owner is dropped but I don't know if that's reasonable.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing AsRaw, FromRaw, AsRawFd, and AsRawHandle traits and the proposed RawOsWrite, RawOsRead, RawOsSeek, and RawOsMeta markers. Done means resolving the validity and AsRaw lifetime guarantees, deciding which operations each marker covers, and documenting the resulting trait design in an RFC.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.