abi_stable/erased_types/
interfaces.rs

1use super::*;
2use std::marker::PhantomData;
3
4/// Implements `InterfaceType`, requiring `Send + Sync + Clone`
5#[repr(C)]
6#[derive(StableAbi)]
7#[sabi(impl_InterfaceType(Send, Sync, Clone))]
8pub struct CloneInterface;
9
10//////////////////////////////////////////////
11
12/// Implements `InterfaceType`, requiring `Send + Sync + Debug + Clone + Eq`
13#[repr(C)]
14#[derive(StableAbi)]
15#[sabi(impl_InterfaceType(Send, Sync, Debug, Clone, Eq))]
16pub struct CloneEqInterface;
17
18//////////////////////////////////////////////
19
20/// Implements `InterfaceType`, requiring `Send + Sync + Debug + Clone + DoubleEndedIterator`
21#[repr(C)]
22#[derive(StableAbi)]
23#[sabi(impl_InterfaceType(Send, Sync, Debug, Clone, DoubleEndedIterator))]
24pub struct DEIteratorCloneInterface<T>(PhantomData<T>);
25
26impl<T> DEIteratorCloneInterface<T> {
27    ///
28    pub const NEW: Self = Self(PhantomData);
29}
30
31impl<'a, T: 'a> IteratorItem<'a> for DEIteratorCloneInterface<T> {
32    type Item = T;
33}
34
35//////////////////////////////////////////////
36
37/// Implements `InterfaceType`, requiring `Send + Sync + Default`
38#[repr(C)]
39#[derive(StableAbi)]
40#[sabi(impl_InterfaceType(Send, Sync, Default))]
41pub struct DefaultInterface;
42
43//////////////////////////////////////////////
44
45/// Implements `InterfaceType`, requiring `Unpin`
46#[repr(C)]
47#[derive(StableAbi)]
48#[sabi(impl_InterfaceType(Unpin))]
49pub struct UnpinInterface;
50
51//////////////////////////////////////////////
52
53/// Implements `InterfaceType`, requiring `Send + Sync + Debug + Eq + Default`
54#[repr(C)]
55#[derive(StableAbi)]
56#[sabi(impl_InterfaceType(Send, Sync, Debug, Eq, Default))]
57pub struct DebugDefEqInterface;
58
59//////////////////////////////////////////////
60
61/// Implements `InterfaceType`, requiring `Send + Sync + Debug + PartialEq`
62#[repr(C)]
63#[derive(StableAbi)]
64#[sabi(impl_InterfaceType(Send, Sync, Debug, PartialEq))]
65pub struct PartialEqInterface;
66
67//////////////////////////////////////////////
68
69/// Implements `InterfaceType`, requiring `Send + Sync + Debug + std::fmt::Write`
70#[repr(C)]
71#[derive(StableAbi)]
72#[sabi(impl_InterfaceType(Send, Sync, Debug, FmtWrite))]
73pub struct FmtWriteInterface;
74
75//////////////////////////////////////////////
76
77/// Implements `InterfaceType`, requiring `std::io::Write`
78#[repr(C)]
79#[derive(StableAbi)]
80#[sabi(impl_InterfaceType(IoWrite))]
81pub struct IoWriteInterface;
82
83//////////////////////////////////////////////
84
85/// Implements `InterfaceType`, requiring `Send + Sync + Debug + Display`
86#[repr(C)]
87#[derive(StableAbi)]
88#[sabi(impl_InterfaceType(Send, Sync, Debug, Display))]
89pub struct DebugDisplayInterface;
90
91//////////////////////////////////////////////
92
93/// Implements `InterfaceType`, requiring `Send + Sync + Iterator<Item = T>`
94#[repr(C)]
95#[derive(StableAbi)]
96#[sabi(impl_InterfaceType(Send, Sync, Iterator))]
97pub struct IteratorInterface<T>(PhantomData<T>);
98
99impl<T> IteratorInterface<T> {
100    ///
101    pub const NEW: Self = Self(PhantomData);
102}
103
104impl<'a, T: 'a> IteratorItem<'a> for IteratorInterface<T> {
105    type Item = T;
106}
107
108//////////////////////////////////////////////
109
110/// Implements `InterfaceType`, requiring `Send + Sync + DoubleEndedIterator<Item = T>`
111#[repr(C)]
112#[derive(StableAbi)]
113#[sabi(impl_InterfaceType(Send, Sync, DoubleEndedIterator))]
114pub struct DEIteratorInterface<T>(PhantomData<T>);
115
116impl<T> DEIteratorInterface<T> {
117    ///
118    pub const NEW: Self = Self(PhantomData);
119}
120
121impl<'a, T: 'a> IteratorItem<'a> for DEIteratorInterface<T> {
122    type Item = T;
123}