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
62
63
64
65
use super::*;

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ContinueArguments {
    pub thread_id: u64,
    pub single_thread: bool,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ContinueResponse {
    pub all_threads_continued: bool,
}

impl From<ContinueArguments> for Value {
    fn from(args: ContinueArguments) -> Self {
        let ContinueArguments {
            thread_id,
            single_thread,
        } = args;

        let thread_id = utils::attribute_u64("threadId", thread_id);
        let single_thread = utils::attribute_bool_optional("singleThread", single_thread);

        utils::finalize_object(thread_id.chain(single_thread))
    }
}

impl TryFrom<&Map<String, Value>> for ContinueArguments {
    type Error = Error;

    fn try_from(map: &Map<String, Value>) -> Result<Self, Self::Error> {
        let thread_id = utils::get_u64(map, "threadId")?;
        let single_thread = utils::get_bool_optional(map, "singleThread")?;

        Ok(Self {
            thread_id,
            single_thread,
        })
    }
}

impl TryFrom<&Map<String, Value>> for ContinueResponse {
    type Error = Error;

    fn try_from(map: &Map<String, Value>) -> Result<Self, Self::Error> {
        let all_threads_continued = utils::get_bool_optional(map, "allThreadsContinued")?;

        Ok(Self {
            all_threads_continued,
        })
    }
}

impl From<ContinueResponse> for Value {
    fn from(response: ContinueResponse) -> Self {
        let ContinueResponse {
            all_threads_continued,
        } = response;

        let all_threads_continued =
            utils::attribute_bool("allThreadsContinued", all_threads_continued);

        utils::finalize_object(all_threads_continued)
    }
}