hepmc2
Read and write event files in the hepmc2 format, also known as
IO_GenEvent.
Caveats
This crate is inspired by the code for the ReaderAsciiHepMC2 in the
HepMC3 library, version
3.2.0. The aim is to be fully compatible, but be aware that the
current tests are not exhaustive.
Example
// Read events from `events_in.hepmc2` and write them to `events_out.hepmc2`
use ;
use BufReader;
use File;
let input = new;
let in_events = from;
let output = create?;
let mut writer = try_from?;
for event in in_events
writer.finish?;
Async API
By default this crate enables the sync feature which exposes a sync API. You
can however switch to using a tokio-backed async API by disabling the sync
feature and enabling the tokio feature.
Either run the following in the root of your crate:
or make sure a line like the following is present in your Cargo.toml:
= { = "0.6.0", = false, = ["tokio"] }
The async API is exactly the same as the sync one but IO operations will return
futures that you will, as usual, need to call await on.
Example
// Read events from `events_in.hepmc2` and write them to `events_out.hepmc2`
use ;
use BufReader;
use File;
let input = new;
let mut in_events = from;
let output = create.await?;
let mut writer = try_from.await?;
while let Some = in_events.next.await
writer.finish.await?;
License: GPL-3.0-or-later