Skip to main content

dope_sys/io/request/
mod.rs

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