dope_sys/memory/buffer/
raw.rs1use o3::buffer;
2
3use crate::memory;
4
5type Extent<P> = <P as Pending>::Extent;
6type Rejection<P> = (
7 P,
8 <Extent<P> as memory::raw::Extent>::Length,
9 <Extent<P> as memory::raw::Extent>::Capacity,
10);
11
12pub trait Select {
14 type Index: Copy;
15 type Pending: Token<Index = Self::Index>
16 + Pending<
17 Complete: Token<
18 Index = Self::Index,
19 Length = <Extent<Self::Pending> as memory::raw::Extent>::Length,
20 >,
21 >;
22
23 unsafe fn select(&self, index: Self::Index) -> Result<Self::Pending, Self::Index>;
27}
28
29pub unsafe trait Token {
33 type Index: Copy;
34 type Length: Copy;
35
36 fn index(&self) -> Self::Index;
37 fn length(&self) -> Self::Length;
38}
39
40pub trait Context<T: Token>: buffer::raw::Fixed<T> {
42 unsafe fn bytes<'a>(&'a self, buffer: &'a T) -> &'a [u8];
46}
47
48pub trait Pending: Sized {
50 type Extent: memory::raw::Extent;
51 type Complete;
52
53 fn try_complete(
54 self,
55 len: <Self::Extent as memory::raw::Extent>::Length,
56 ) -> Result<Self::Complete, Rejection<Self>>;
57}