Skip to main content

dope_sys/engine/
raw.rs

1use std::time;
2
3use o3::mem;
4
5use crate::{
6    engine::{Buffer, Source, register},
7    io::reactor::event,
8    table::token::host,
9};
10
11type Created<S, C, G, E> = (
12    <S as Source<C>>::Backend,
13    <<S as Source<C>>::Backend as Buffer>::Context,
14    <S as Create<C, G, E>>::Receive,
15);
16
17/// Arms a shutdown source owned outside the native engine.
18pub trait Register {
19    /// # Safety
20    /// Retain the source's exact descriptor until engine quiescence or destruction,
21    /// including when a submission is published before this method returns an error.
22    unsafe fn register(&mut self, source: register::Source<'_>) -> Result<(), register::Error>;
23}
24
25/// Commits and waits while the host retains the registered operation owners.
26pub trait Poll {
27    type Context;
28    type Error: Copy + Eq;
29
30    /// # Safety
31    /// Registered storage and kernel identities remain valid for this driver's flights.
32    unsafe fn wait<'a, Tag>(
33        &'a mut self,
34        quota: mem::raw::Shared<'_, Tag>,
35        timeout: Option<time::Duration>,
36        busy: bool,
37    ) -> Result<(), Self::Error>
38    where
39        Self::Context: 'a;
40}
41
42/// Creates the native runtime and its external receive owners in backend order.
43pub trait Create<C, G, E>: Source<C>
44where
45    Self::Backend: Buffer,
46{
47    type Receive;
48
49    /// # Safety
50    /// Retain the returned buffer context alongside the backend until native
51    /// quiescence and destruction, including every returned partial cleanup owner.
52    unsafe fn try_new(config: &G) -> Result<Created<Self, C, G, E>, E>;
53}
54
55/// # Safety
56/// Keep every returned part paired with this engine through native completion and reclamation.
57pub unsafe trait Owner<'d, N, F, D>
58where
59    F: host::raw::Drain + 'd,
60{
61    type Report: event::Report<Event = F::Reported>;
62
63    /// # Safety
64    /// Keep the parts paired and end this loan before application I/O re-entry.
65    unsafe fn parts(
66        &mut self,
67    ) -> (
68        &mut N,
69        &'d F,
70        D,
71        &mut Self::Report,
72        &mut Option<register::Source<'d>>,
73        &mut bool,
74    );
75}