Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventData::json should take payload by shared reference #180

Open
hseeberger opened this issue May 14, 2024 · 0 comments
Open

EventData::json should take payload by shared reference #180

hseeberger opened this issue May 14, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@hseeberger
Copy link

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.

@YoEight YoEight added the enhancement New feature or request label Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants