| 1 | pub mod destructor; |
| 2 | pub use self::destructor::Destructor; |
| 3 | |
| 4 | pub mod input; |
| 5 | pub use self::input::Input; |
| 6 | |
| 7 | pub mod output; |
| 8 | pub use self::output::Output; |
| 9 | |
| 10 | #[doc (hidden)] |
| 11 | pub mod common; |
| 12 | |
| 13 | pub enum Context { |
| 14 | Input(Input), |
| 15 | Output(Output), |
| 16 | } |
| 17 | |
| 18 | unsafe impl Send for Context {} |
| 19 | |
| 20 | impl Context { |
| 21 | pub fn is_input(&self) -> bool { |
| 22 | matches!(*self, Context::Input(..)) |
| 23 | } |
| 24 | |
| 25 | pub fn input(self) -> Input { |
| 26 | if let Context::Input(context) = self { |
| 27 | return context; |
| 28 | } |
| 29 | |
| 30 | unreachable!(); |
| 31 | } |
| 32 | |
| 33 | pub fn is_output(&self) -> bool { |
| 34 | matches!(*self, Context::Output(..)) |
| 35 | } |
| 36 | |
| 37 | pub fn output(self) -> Output { |
| 38 | if let Context::Output(context) = self { |
| 39 | return context; |
| 40 | } |
| 41 | |
| 42 | unreachable!(); |
| 43 | } |
| 44 | } |
| 45 | |