pub struct Reader<T> { /* private fields */ }
Expand description
Reader for the LHEF format
Implementations§
source§impl<T: BufRead> Reader<T>
impl<T: BufRead> Reader<T>
sourcepub fn new(stream: T) -> Result<Reader<T>, Box<dyn Error>>
pub fn new(stream: T) -> Result<Reader<T>, Box<dyn Error>>
Create a new LHEF reader
Example
let file = std::fs::File::open("events.lhe").unwrap();
let file = std::io::BufReader::new(file);
let reader = lhef::Reader::new(file).unwrap();
sourcepub fn xml_header(&self) -> &Option<XmlTree>
pub fn xml_header(&self) -> &Option<XmlTree>
Get the LHEF xml header
sourcepub fn hepeup(&mut self) -> Result<Option<HEPEUP>, Box<dyn Error>>
pub fn hepeup(&mut self) -> Result<Option<HEPEUP>, Box<dyn Error>>
Get the next event in HEPEUP format
Example
let file = std::fs::File::open("events.lhe").unwrap();
let file = std::io::BufReader::new(file);
let mut reader = lhef::Reader::new(file).unwrap();
let event = reader.hepeup().unwrap();
match event {
Some(event) => println!("Found an event."),
None => println!("Reached end of event file."),
}