pub struct Tree { /* private fields */ }
Expand description

Tree of Collections for saving to a file.

Implementations

Returns new Tree

Name is the only required metadata.

Arguments
  • name - string
Example
use calcify::Tree;
use calcify::Collection;
use calcify::Bin;
use calcify::ThreeVec;

let f_col: Collection<f64> = Collection::from(vec![0.0,0.0]);
let mut v3_col: Collection<ThreeVec> = Collection::empty();
for _i in 0..9999 {v3_col.push(ThreeVec::random(1.0));}
let col_hist: Collection<Bin> = v3_col.map(ThreeVec::r).hist(50);
let mut ttree = Tree::new("Test_Tree");
ttree.add_field("Desc", "This is a Tree for testing.");
ttree.add_branch("fcol", f_col, "f64");
ttree.add_branch("col_3v", v3_col, "ThreeVec");
ttree.add_branch("hist_3v", col_hist, "Bin");

Inserts new branch into Tree.

Arguments
  • key - Hash key, String
  • b - Branch, Collection<T: Serializable>
  • t - Collection subtype, String, one of “f64”, “String”, “ThreeVec”, “ThreeMat”, “FourVec”, “FourMat”, “Bin”, “Point”, “Object”
Panics
  • t is invalid

Returns Branch from a Trees

Arguments

key - String

Example
use calcify::Tree;
use calcify::Collection;
use calcify::Bin;

let f_col: Collection<f64> = Collection::from(vec![0.0,0.0]);
let b_col: Collection<Bin> = Collection::from(vec![Bin::new(0.0,1.0,10),Bin::new(1.0,2.0,10),Bin::new(2.0,3.0,10)]);
let mut ttree = Tree::new("Test_Tree");
ttree.add_branch("fcol", f_col, "f64").expect("KeyError");
ttree.add_branch("bCol", b_col, "Bin").expect("KeyError");

let ex_f_col: Collection<f64> = ttree.get_branch("fcol").unwrap().extract().unwrap();
let mut ex_b_col: Collection<Bin> = ttree.get_branch("bCol").unwrap().extract().unwrap();

assert_eq!(Collection::from(vec![0.0,0.0]),ex_f_col);
assert_eq!(Collection::from(vec![Bin::new(0.0,1.0,10),Bin::new(1.0,2.0,10),Bin::new(2.0,3.0,10)]),ex_b_col);

Returns Collection from a Trees

Arguments

key - String

Example
use calcify::Tree;
use calcify::Collection;
use calcify::Bin;

let f_col: Collection<f64> = Collection::from(vec![0.0,0.0]);
let b_col: Collection<Bin> = Collection::from(vec![Bin::new(0.0,1.0,10),Bin::new(1.0,2.0,10),Bin::new(2.0,3.0,10)]);
let mut ttree = Tree::new("Test_Tree");
ttree.add_branch("fcol", f_col, "f64").expect("KeyError");
ttree.add_branch("bCol", b_col, "Bin").expect("KeyError");

let ex_f_col: Collection<f64> = ttree.read_branch("fcol").unwrap();
let mut ex_b_col: Collection<Bin> = ttree.read_branch("bCol").unwrap();
// read from buffer
ex_b_col = ttree.read_branch("bCol").unwrap();

assert_eq!(Collection::from(vec![0.0,0.0]),ex_f_col);
assert_eq!(Collection::from(vec![Bin::new(0.0,1.0,10),Bin::new(1.0,2.0,10),Bin::new(2.0,3.0,10)]),ex_b_col);

Trait Implementations

Return Self from string

Return a tuple of Self and a &u8 of remaining unparsed bytes from a byte array

Read json file to Self.

Read msg file to Self.

Return object intensive json string Read more

Return Result wrapped Vec in MsgPack Format is not like to_json it is array intensive not object Read more

Write Self as json to file.

Write Self as msg to file.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.