• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! Snapshots of runtime state.
2 //!
3 //! See [Handle::dump][crate::runtime::Handle::dump].
4 
5 use std::fmt;
6 
7 /// A snapshot of a runtime's state.
8 ///
9 /// See [Handle::dump][crate::runtime::Handle::dump].
10 #[derive(Debug)]
11 pub struct Dump {
12     tasks: Tasks,
13 }
14 
15 /// Snapshots of tasks.
16 ///
17 /// See [Handle::dump][crate::runtime::Handle::dump].
18 #[derive(Debug)]
19 pub struct Tasks {
20     tasks: Vec<Task>,
21 }
22 
23 /// A snapshot of a task.
24 ///
25 /// See [Handle::dump][crate::runtime::Handle::dump].
26 #[derive(Debug)]
27 pub struct Task {
28     trace: Trace,
29 }
30 
31 /// An execution trace of a task's last poll.
32 ///
33 /// See [Handle::dump][crate::runtime::Handle::dump].
34 #[derive(Debug)]
35 pub struct Trace {
36     inner: super::task::trace::Trace,
37 }
38 
39 impl Dump {
new(tasks: Vec<Task>) -> Self40     pub(crate) fn new(tasks: Vec<Task>) -> Self {
41         Self {
42             tasks: Tasks { tasks },
43         }
44     }
45 
46     /// Tasks in this snapshot.
tasks(&self) -> &Tasks47     pub fn tasks(&self) -> &Tasks {
48         &self.tasks
49     }
50 }
51 
52 impl Tasks {
53     /// Iterate over tasks.
iter(&self) -> impl Iterator<Item = &Task>54     pub fn iter(&self) -> impl Iterator<Item = &Task> {
55         self.tasks.iter()
56     }
57 }
58 
59 impl Task {
new(trace: super::task::trace::Trace) -> Self60     pub(crate) fn new(trace: super::task::trace::Trace) -> Self {
61         Self {
62             trace: Trace { inner: trace },
63         }
64     }
65 
66     /// A trace of this task's state.
trace(&self) -> &Trace67     pub fn trace(&self) -> &Trace {
68         &self.trace
69     }
70 }
71 
72 impl fmt::Display for Trace {
fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result73     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
74         self.inner.fmt(f)
75     }
76 }
77