1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

use core::marker::PhantomData;

#[derive(Debug)]
pub struct Checkpoint<Endpoint, Location, Op> {
    pub(crate) id: u64,
    endpoint: PhantomData<Endpoint>,
    location: PhantomData<Location>,
    op: PhantomData<Op>,
}

impl<Endpoint, Location, Op> Checkpoint<Endpoint, Location, Op> {
    pub(crate) fn new(id: u64) -> Self {
        Self {
            id,
            endpoint: PhantomData,
            location: PhantomData,
            op: PhantomData,
        }
    }
}

#[derive(Debug)]
pub struct Park;

#[derive(Debug)]
pub struct Unpark;

macro_rules! sync {
    ($endpoint:ty, $location:ty) => {
        pub fn park(
            &mut self,
            checkpoint: crate::scenario::builder::checkpoint::Checkpoint<
                $endpoint,
                $location,
                crate::scenario::builder::checkpoint::Park,
            >,
        ) -> &mut Self {
            self.ops.push(crate::operation::Connection::Park {
                checkpoint: checkpoint.id,
            });
            self
        }

        pub fn unpark(
            &mut self,
            checkpoint: crate::scenario::builder::checkpoint::Checkpoint<
                $endpoint,
                $location,
                crate::scenario::builder::checkpoint::Unpark,
            >,
        ) -> &mut Self {
            self.ops.push(crate::operation::Connection::Unpark {
                checkpoint: checkpoint.id,
            });
            self
        }
    };
}