fullmac_helpers/
recorded_request_stream.rs1use fidl_fuchsia_wlan_fullmac::{self as fidl_fullmac, WlanFullmacImpl_Request};
5use futures::StreamExt;
6
7#[derive(Clone, Debug, PartialEq)]
9pub enum FullmacRequest {
10 Query,
11 QuerySecuritySupport,
12 StartScan(fidl_fullmac::WlanFullmacImplStartScanRequest),
13 Connect(fidl_fullmac::WlanFullmacImplConnectRequest),
14 Reconnect(fidl_fullmac::WlanFullmacImplReconnectRequest),
15 AuthResp(fidl_fullmac::WlanFullmacImplAuthRespRequest),
16 Deauth(fidl_fullmac::WlanFullmacImplDeauthRequest),
17 AssocResp(fidl_fullmac::WlanFullmacImplAssocRespRequest),
18 Disassoc(fidl_fullmac::WlanFullmacImplDisassocRequest),
19 StartBss(fidl_fullmac::WlanFullmacImplStartBssRequest),
20 StopBss(fidl_fullmac::WlanFullmacImplStopBssRequest),
21 SetKeys(fidl_fullmac::WlanFullmacImplSetKeysRequest),
22 EapolTx(fidl_fullmac::WlanFullmacImplEapolTxRequest),
23 GetIfaceStats,
24 GetIfaceHistogramStats,
25 SaeHandshakeResp(fidl_fullmac::WlanFullmacImplSaeHandshakeRespRequest),
26 SaeFrameTx(fidl_fullmac::SaeFrame),
27 WmmStatusReq,
28 OnLinkStateChanged(fidl_fullmac::WlanFullmacImplOnLinkStateChangedRequest),
29
30 Init,
33}
34
35pub struct RecordedRequestStream {
39 request_stream: fidl_fullmac::WlanFullmacImpl_RequestStream,
40 history: Vec<FullmacRequest>,
41}
42
43impl RecordedRequestStream {
44 pub fn new(request_stream: fidl_fullmac::WlanFullmacImpl_RequestStream) -> Self {
45 Self { request_stream, history: Vec::new() }
46 }
47
48 pub fn history(&self) -> &[FullmacRequest] {
49 &self.history[..]
50 }
51
52 pub fn clear_history(&mut self) {
53 self.history.clear();
54 }
55
56 pub async fn next(&mut self) -> fidl_fullmac::WlanFullmacImpl_Request {
60 let request = self
61 .request_stream
62 .next()
63 .await
64 .unwrap()
65 .expect("Could not get next request in fullmac request stream");
66 match &request {
67 WlanFullmacImpl_Request::Query { .. } => self.history.push(FullmacRequest::Query),
68 WlanFullmacImpl_Request::QuerySecuritySupport { .. } => {
69 self.history.push(FullmacRequest::QuerySecuritySupport)
70 }
71 WlanFullmacImpl_Request::StartScan { payload, .. } => {
72 self.history.push(FullmacRequest::StartScan(payload.clone()))
73 }
74 WlanFullmacImpl_Request::Connect { payload, .. } => {
75 self.history.push(FullmacRequest::Connect(payload.clone()))
76 }
77 WlanFullmacImpl_Request::Reconnect { payload, .. } => {
78 self.history.push(FullmacRequest::Reconnect(payload.clone()))
79 }
80 WlanFullmacImpl_Request::AuthResp { payload, .. } => {
81 self.history.push(FullmacRequest::AuthResp(payload.clone()))
82 }
83 WlanFullmacImpl_Request::Deauth { payload, .. } => {
84 self.history.push(FullmacRequest::Deauth(payload.clone()))
85 }
86 WlanFullmacImpl_Request::AssocResp { payload, .. } => {
87 self.history.push(FullmacRequest::AssocResp(payload.clone()))
88 }
89 WlanFullmacImpl_Request::Disassoc { payload, .. } => {
90 self.history.push(FullmacRequest::Disassoc(payload.clone()))
91 }
92 WlanFullmacImpl_Request::StartBss { payload, .. } => {
93 self.history.push(FullmacRequest::StartBss(payload.clone()))
94 }
95 WlanFullmacImpl_Request::StopBss { payload, .. } => {
96 self.history.push(FullmacRequest::StopBss(payload.clone()))
97 }
98 WlanFullmacImpl_Request::SetKeys { payload, .. } => {
99 self.history.push(FullmacRequest::SetKeys(payload.clone()))
100 }
101 WlanFullmacImpl_Request::EapolTx { payload, .. } => {
102 self.history.push(FullmacRequest::EapolTx(payload.clone()))
103 }
104 WlanFullmacImpl_Request::GetIfaceStats { .. } => {
105 self.history.push(FullmacRequest::GetIfaceStats)
106 }
107 WlanFullmacImpl_Request::GetIfaceHistogramStats { .. } => {
108 self.history.push(FullmacRequest::GetIfaceHistogramStats)
109 }
110 WlanFullmacImpl_Request::SaeHandshakeResp { payload, .. } => {
111 self.history.push(FullmacRequest::SaeHandshakeResp(payload.clone()))
112 }
113 WlanFullmacImpl_Request::SaeFrameTx { frame, .. } => {
114 self.history.push(FullmacRequest::SaeFrameTx(frame.clone()))
115 }
116 WlanFullmacImpl_Request::WmmStatusReq { .. } => {
117 self.history.push(FullmacRequest::WmmStatusReq)
118 }
119 WlanFullmacImpl_Request::OnLinkStateChanged { payload, .. } => {
120 self.history.push(FullmacRequest::OnLinkStateChanged(payload.clone()))
121 }
122 WlanFullmacImpl_Request::Init { .. } => self.history.push(FullmacRequest::Init),
123
124 _ => panic!("Unrecognized Fullmac request {:?}", request),
125 }
126 request
127 }
128}