Skip to main content

dope_sys/io/request/
mod.rs

1mod complete;
2mod context;
3mod source;
4
5use std::{mem::MaybeUninit, os::fd};
6
7use o3::buffer::bytes::bounded;
8
9pub use complete::Complete;
10pub use context::Context;
11pub use source::Source;
12
13use crate::io::file;
14
15/// File requests retaining their descriptor, path, options, and buffer borrows.
16pub trait Request<'a>: Sized {
17    type Buffer;
18    type Options;
19    type Metadata;
20
21    fn options(flags: file::Open, mode: file::Mode) -> Self::Options;
22    fn open(dir: fd::BorrowedFd<'a>, path: &'a std::ffi::CStr, options: &'a Self::Options) -> Self;
23    fn metadata(file: fd::BorrowedFd<'a>, output: &'a mut Self::Metadata) -> Self;
24    fn read(
25        file: fd::BorrowedFd<'a>,
26        output: bounded::Value<&'a mut [MaybeUninit<u8>]>,
27        offset: file::Offset,
28    ) -> Self;
29    fn write(file: fd::BorrowedFd<'a>, input: Self::Buffer, offset: file::Offset) -> Self;
30    /// Writes at the owned descriptor's current position, honoring `O_APPEND`.
31    fn write_current(file: fd::BorrowedFd<'a>, input: Self::Buffer) -> Self;
32    fn sync(file: fd::BorrowedFd<'a>, mode: file::Sync) -> Self;
33    fn rename(dir: fd::BorrowedFd<'a>, old: &'a std::ffi::CStr, new: &'a std::ffi::CStr) -> Self;
34    fn unlink(dir: fd::BorrowedFd<'a>, name: &'a std::ffi::CStr) -> Self;
35}