EventStoreDB-Client-Rust
EventStoreDB-Client-Rust copied to clipboard
EventData::json should take payload by shared reference
Currently the signature of EventData::json looks like this:
pub fn json<S, P>(event_type: S, payload: P) -> serde_json::Result<EventData>
The payload is later only used by shared reference, there is no need for an owned value:
let payload = Bytes::from(serde_json::to_vec(&payload)?);
Therefore the signature could be changed (notice &P instead of P):
pub fn json<S, P>(event_type: S, payload: &P) -> serde_json::Result<EventData>
This would avoid cloning the event in cases where it is needed after invoking EventData::json.