oxide_update_engine/macros.rs
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5/// Defines type aliases for engine-crate types parameterized by a
6/// particular [`EngineSpec`](crate::types::spec::EngineSpec).
7///
8/// This macro defines a number of type aliases. For example:
9///
10/// ```ignore
11/// oxide_update_engine::define_update_engine!(pub(crate) MySpec);
12/// ```
13///
14/// defines a number of type aliases, each of which are of the form:
15///
16/// ```ignore
17/// pub(crate) type UpdateEngine<'a, S = MySpec> =
18/// oxide_update_engine::UpdateEngine<'a, S>;
19/// pub(crate) type StepContext<S = MySpec> =
20/// oxide_update_engine::StepContext<S>;
21/// // ... and so on.
22/// ```
23///
24/// For types-crate aliases (events, buffers, etc.), use the companion
25/// macro
26/// [`oxide_update_engine_types::define_update_engine_types!`](https://docs.rs/oxide-update-engine-types).
27#[macro_export]
28macro_rules! define_update_engine {
29 ($v:vis $spec_type:ty) => {
30 $v type UpdateEngine<'a, S = $spec_type> =
31 $crate::UpdateEngine<'a, S>;
32 $v type ComponentRegistrar<'engine, 'a, S = $spec_type> =
33 $crate::ComponentRegistrar<'engine, 'a, S>;
34 $v type StepContext<S = $spec_type> =
35 $crate::StepContext<S>;
36 $v type StepHandle<T, S = $spec_type> =
37 $crate::StepHandle<T, S>;
38 $v type SharedStepHandle<T, S = $spec_type> =
39 $crate::SharedStepHandle<T, S>;
40 $v type StepResult<T, S = $spec_type> =
41 $crate::StepResult<T, S>;
42 $v type StepSuccess<T, S = $spec_type> =
43 $crate::StepSuccess<T, S>;
44 $v type StepWarning<T, S = $spec_type> =
45 $crate::StepWarning<T, S>;
46 $v type StepSkipped<T, S = $spec_type> =
47 $crate::StepSkipped<T, S>;
48 $v type ExecutionError<S = $spec_type> =
49 $crate::ExecutionError<S>;
50 };
51}