Derive Macro oxyroot_derive::ReadFromTree

source ·
#[derive(ReadFromTree)]
{
    // Attributes available to this derive:
    #[oxyroot]
}
Expand description

Derive macro in order to read struct data from TTree. Branch names and types are deduced from fields.

use oxyroot::{ReadFromTree, RootFile};
#[derive(ReadFromTree)]
struct MyStruct {
    a: i32,     // will be read from branch "a" as 32 bits integer
    s: String,  // will be read from branch "s" String
}
let tree = RootFile::open("in.root").unwrap().get_tree("tree").unwrap();
MyStruct::from_tree(&tree).unwrap().map(|m: MyStruct | {  /* do something with m */ });

By using attribute #[oxyroot(rename = "...")], it is possible to use different branch name :

use oxyroot::{ReadFromTree};
#[derive(ReadFromTree)]///
 struct MyStruct {
     #[oxyroot(rename = "b")]
     a: i32,     // will be read from branch *"b"* as 32 bits integer
     s: String,  // will be read from branch "s" String
 }