You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(client): adapt internal client_request API to be easier to implement correctly (#15)
* fix(client): adapt internal client_request API to be easier to implement correctly
This also fixes an issue with handling DB errors when reading events
* fix(client): remove unnecessarily restricting change to build_stream API of ClientRequest
* chore(client): add comments to stream parsing to make complex parts easier to understand especially for new rustaceans
Signed-off-by: Raphael Höser <[email protected]>
---------
Signed-off-by: Raphael Höser <[email protected]>
Co-authored-by: Kuro <[email protected]>
// This line does the heavy lifting of parsing the json-nd line into the correct type.
101
+
// There's some Rust typesystem glory involved here, so let's break it down:
102
+
// First of all `serde_json::from_str` is used to parse any json `&str` into the type we want to have (in this case a `StreamLineItem`).
103
+
// `StreamLineItem` in turn is generic over `Self::ItemType`, which is the type that is expected by the exact response implementation and can change.
104
+
// This means, that this will throw an error if the line is invalid json or the string cannot be parsed into an error, heartbeat or the expected type.
105
+
// Because of this, we can guarantee after this line, that the payload of the `StreamLineItem` is of the correct type and no further checks are needed.
0 commit comments