MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / parse_response_streams

Function parse_response_streams

crates/agent/tests/common/mod.rs:269–291  ·  view source on GitHub ↗
(content: impl AsRef<str>)

Source from the content-addressed store, hash-verified

267}
268
269pub async fn parse_response_streams(content: impl AsRef<str>) -> Result<MockResponseStreams> {
270 let mut stream: Vec<Vec<StreamResult>> = Vec::new();
271 let mut curr_stream = Vec::new();
272 for line in content.as_ref().lines() {
273 // ignore comments
274 if line.starts_with("//") {
275 continue;
276 }
277 // empty line -> new response stream
278 if line.is_empty() && !curr_stream.is_empty() {
279 let mut temp = Vec::new();
280 std::mem::swap(&mut temp, &mut curr_stream);
281 stream.push(temp);
282 continue;
283 }
284 // otherwise, push the value to the current response
285 curr_stream.push(serde_json::from_str(line)?);
286 }
287 if !curr_stream.is_empty() {
288 stream.push(curr_stream);
289 }
290 Ok(stream)
291}

Callers 1

test_agent_defaultsFunction · 0.85

Calls 2

as_refMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected