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

OS specific File APIs #2636

Open
nomad010 opened this issue Jun 29, 2020 · 7 comments
Open

OS specific File APIs #2636

nomad010 opened this issue Jun 29, 2020 · 7 comments
Labels
A-tokio Area: The main tokio crate C-feature-accepted Category: A feature request that has been accepted pending implementation. C-feature-request Category: A feature request. E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Experience needed to fix: Medium / intermediate M-fs Module: tokio/fs

Comments

@nomad010
Copy link

It would be nice to have the OS specific implementations of File Read/Write methods in tokio as a nice to have. I noticed that there was a closed PR on the topic here #488 and the commits have become stale in the meantime.

Is there any resistance to this feature? Would this be doable as a first issue? If so, I'd like to try my hand at implementing it.

@nomad010 nomad010 added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels Jun 29, 2020
@Darksonn Darksonn added the M-fs Module: tokio/fs label Jun 30, 2020
@Darksonn Darksonn changed the title OS specific implementations OS specific File APIs Jun 30, 2020
@Darksonn
Copy link
Contributor

I am fine with adding this. Consider taking a look at #2524 and #2515 for inspiration.

@Darksonn Darksonn added C-feature-accepted Category: A feature request that has been accepted pending implementation. E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Experience needed to fix: Medium / intermediate labels Jul 28, 2020
@Yoric
Copy link

Yoric commented Oct 2, 2020

So, porting FileExt? If it's low-priority, I could take a look.

@Darksonn
Copy link
Contributor

Darksonn commented Oct 2, 2020

Our priority is currently things on the v0.3 and v1.0 milestones, but feel free to take a look.

@Yoric
Copy link

Yoric commented Oct 4, 2020

Our priority is currently things on the v0.3 and v1.0 milestones, but feel free to take a look.

Is there some issue where I would be more useful? I'm fairly new at tokio, but happy to learn!

@Yoric
Copy link

Yoric commented Oct 4, 2020

Ok, I've toyed with it a little and I have an early prototype of poll_read_at and a few difficulties deciding where it should go.

Should I introduce

/// Implemented by `std::fs::File` under Unix.
pub trait ReadAt {
    fn read_at(&self, buf: &mut [u8], offset: u64) -> std::io::Result<usize>;
}

pub trait AsyncReadAt {
    fn poll_read_at(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
        buf: &mut ReadBuf<'_>,
        offset: u64
    ) -> Poll<io::Result<()>>;
}

and

pub trait AsyncReadAtExt {
  fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>;
}

?

(and later the same with poll_seek_read under Windows)

@Darksonn
Copy link
Contributor

Darksonn commented Oct 4, 2020

Having a poll version of it raises a bunch of questions regarding how to design it correctly. I think it is best to wait with this particular feature for now. See the "Pause on adding new APIs" section in #2718, where it is outlined that we currently only accept obviously correct API additions.

I will be happy to provide guidance regarding other places to contribute now on our discord server.

@opiredev

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-accepted Category: A feature request that has been accepted pending implementation. C-feature-request Category: A feature request. E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Experience needed to fix: Medium / intermediate M-fs Module: tokio/fs
Projects
None yet
Development

No branches or pull requests

4 participants