-
Notifications
You must be signed in to change notification settings - Fork 7
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
Async IO access #2
Comments
Thinking we could structure this as: // provided methods: read, write
trait RandomAccess: AsyncRead + AsyncWrite + Drop {
type Error;
fn open() -> Result<Self, Self::Error>
async fn remove(&mut self, offset: u64, length: u64) -> Result<(), Self::Error>
} We could implement the |
Possibly we should also require |
Okay, from talking to @substack, and considering #13, we could make this trait not require any methods, and make it require We could then provide range variants of stdlib methods, while preserving the ability to call stdlib methods directly. The proposed shape of the trait would be (simplified): trait RandomAccessStorage: Read + Write + Seek {
fn read_range(range: Range, buf: &mut [u8]) -> Result<(), Error>;
fn write_offset(offset: usize, buf: &mut [u8]) -> Result<(), Error>;
fn remove_range(range: Range) -> Result<(), Error>;
} AsyncOnce we're comfortable enough with futures we could add the trait RandomAccessStorage: Read + Write + Seek {
fn read_range(range: Range, buf: &mut [u8]) -> Result<(), Error>;
fn write_offset(offset: usize, buf: &mut [u8]) -> Result<(), Error>;
fn remove_range(range: Range) -> Result<(), Error>;
async fn poll_read_range(range: Range, buf: &mut [u8]) -> Result<(), Error>;
async fn poll_write_offset(offset: usize, buf: &mut [u8]) -> Result<(), Error>;
async fn poll_remove_range(range: Range) -> Result<(), Error>;
} We could experiment with creating a first version of our backends that does not rely on async IO libraries directly, and instead calls out to the regular ErgonomicsTo comply with #13, we'd have to remove the core implementation from allocating. But we could add convenience methods to do the allocations for us. However considering there's also |
This is the closest we've gotten so far: https://gist.github.com/rust-play/cf5eb5d7e255957b69dcaf3b9297d9f7
It'd be good to figure out a way in which we can make this work. Probably depends on the new version of https://github.com/alexcrichton/futures-await landing, which will allow us to pass borrowed values into API.
The text was updated successfully, but these errors were encountered: