Skip to content

Commit b46a131

Browse files
committed
Simplify result stream by removing the RowOrSummary enum
The result summary can now only be returned from `finish`, which also consumes the stream. The next_or_summary and *_items_* methods are removed. This also simplifies the API for finish, the summary no longer has to be returned as an option. Before it could have already been returned by a call to next_or_summary, which would result in a None being returned from finish. Having the API like that is also closer to APIs from the product drivers
1 parent 5d9e84e commit b46a131

File tree

2 files changed

+86
-228
lines changed

2 files changed

+86
-228
lines changed

lib/include/result_summary.rs

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,45 +22,18 @@
2222
}
2323

2424
//
25-
// next_or_summary
25+
// next + finish
2626

2727
let mut stream = graph
2828
.execute(query("CREATE (n:Node {prop: 'frobnicate'}) RETURN n"))
2929
.await
3030
.unwrap();
3131

32-
let Ok(Some(row)) = stream.next_or_summary().await else { panic!() };
33-
assert!(row.row().is_some());
34-
assert!(row.summary().is_none());
32+
let Ok(Some(row)) = stream.next().await else { panic!() };
33+
assert_item(row.to().unwrap());
3534

36-
assert_item(row.row().unwrap().to().unwrap());
37-
38-
let Ok(Some(row)) = stream.next_or_summary().await else { panic!() };
39-
assert!(row.row().is_none());
40-
assert!(row.summary().is_some());
41-
42-
assert_summary(row.summary().unwrap());
43-
44-
45-
//
46-
// as_items
47-
48-
let mut stream = graph
49-
.execute(query("CREATE (n:Node {prop: 'frobnicate'}) RETURN n"))
50-
.await
51-
.unwrap();
52-
53-
let items = stream.as_items::<N>()
54-
.try_collect::<Vec<_>>()
55-
.await
56-
.unwrap();
57-
58-
for item in items {
59-
match item {
60-
RowItem::Row(row) => assert_item(row),
61-
RowItem::Summary(summary) => assert_summary(&summary),
62-
}
63-
}
35+
let Ok(summary) = stream.finish().await else { panic!() };
36+
assert_summary(&summary);
6437

6538

6639
//
@@ -76,7 +49,7 @@
7649
.await
7750
.unwrap();
7851

79-
let Ok(Some(summary)) = stream.finish().await else { panic!() };
52+
let Ok(summary) = stream.finish().await else { panic!() };
8053

8154
for item in items {
8255
assert_item(item);

0 commit comments

Comments
 (0)