Skip to main content

dope_sys/io/request/
mod.rs

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