Skip to content

Commit c2b733d

Browse files
authored
Simplify result summary api (#222)
* 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 * Remove RowItem
1 parent 5d9e84e commit c2b733d

File tree

3 files changed

+85
-268
lines changed

3 files changed

+85
-268
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);

lib/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ pub use crate::errors::{
483483
pub use crate::graph::{query, Graph};
484484
pub use crate::query::{Query, QueryParameter};
485485
pub use crate::row::{Node, Path, Point2D, Point3D, Relation, Row, UnboundedRelation};
486-
pub use crate::stream::{DetachedRowStream, RowItem, RowStream};
486+
pub use crate::stream::{DetachedRowStream, RowStream};
487487
pub use crate::txn::Txn;
488488
pub use crate::types::serde::{
489489
DeError, EndNodeId, Id, Indices, Keys, Labels, Nodes, Offset, Relationships, StartNodeId,

0 commit comments

Comments
 (0)