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
66
67
use crate;
/// Gets the last interaction with the server, if any
///
/// Returns `None` if no interactions have been recorded yet.
///
/// # Example
/// ```no_run
/// use ibapi::trace;
///
/// # async fn example() {
/// if let Some(interaction) = trace::last_interaction().await {
/// println!("Last request: {}", interaction.request);
/// println!("Responses: {:?}", interaction.responses);
/// }
/// # }
/// ```
pub async
/// Records a new request, starting a new interaction
///
/// This function starts tracking a new server interaction. Any subsequent
/// calls to `record_response` will add responses to this interaction until
/// a new request is recorded.
///
/// # Arguments
/// * `message` - The request message being sent to the server
///
/// # Example
/// ```no_run
/// use ibapi::trace;
///
/// # async fn example() {
/// trace::record_request("REQ|123|AAPL|".to_string()).await;
/// # }
/// ```
pub async
/// Records a response message for the current interaction
///
/// Adds a response to the most recent interaction started by `record_request`.
/// If no interaction has been started, this function does nothing.
///
/// # Arguments
/// * `message` - The response message received from the server
///
/// # Example
/// ```no_run
/// use ibapi::trace;
///
/// # async fn example() {
/// trace::record_request("REQ|123|AAPL|".to_string()).await;
/// trace::record_response("RESP|123|150.00|".to_string()).await;
/// trace::record_response("RESP|123|151.00|".to_string()).await;
/// # }
/// ```
pub async