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

feat: EventValues from heterogenous tuples #11

Merged
merged 1 commit into from
Nov 9, 2023

Conversation

sgasse
Copy link
Contributor

@sgasse sgasse commented Nov 9, 2023

So far, we were only able to serialize Vec<T> or iterators of T for one homogenous type T. Users were forced to pre-create an EventValue::List with inner EventValues.

This commit adds From implementations for tuples ranging from 2 to 5 elements where each type can be a different one as long as all of them implement Into<EventValue>.

Example event description

# application: string
# duration: int, milli seconds
00000007 app_ready (application|3),(duration|1|3)
# before
let value = EventValue::List(vec![
    EventValue::String("app1".to_owned()),
    EventValue::Int(Duration::from_secs(7).as_millis() as i32),
]);
write_event_now("module_tag", ).unwrap();

# now
write_event_now("module_tag", ("app1", Duration::from_secs(7).as_millis() as i32)).unwrap();

So far, we were only able to serialize `Vec<T>` or iterators of `T` for
one homogenous type `T`. Users were forced to pre-create an
`EventValue::List` with inner `EventValue`s.

This commit adds `From` implementations for tuples ranging from 2 to 5
elements where each type can be a different one as long as all of them
implement `Into<EventValue>`.
@flxo flxo merged commit a4d079a into flxo:main Nov 9, 2023
8 checks passed
@sgasse sgasse deleted the sgasse/feature/heterogenous_event_types branch November 9, 2023 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants