@@ -15,6 +15,7 @@ pub struct TreeInterface {
15
15
num_nodes : tsk_size_t ,
16
16
array_len : tsk_size_t ,
17
17
flags : TreeFlags ,
18
+ nodes : crate :: NodeTable ,
18
19
}
19
20
20
21
impl TreeInterface {
@@ -24,11 +25,16 @@ impl TreeInterface {
24
25
array_len : tsk_size_t ,
25
26
flags : TreeFlags ,
26
27
) -> Self {
28
+ let nodes = crate :: NodeTable :: new_from_table (
29
+ & mut unsafe { * ( * non_owned_pointer. as_ref ( ) . tree_sequence ) . tables } . nodes ,
30
+ )
31
+ . expect ( "null pointer to tsk_node_table_t" ) ;
27
32
Self {
28
33
non_owned_pointer,
29
34
num_nodes,
30
35
array_len,
31
36
flags,
37
+ nodes,
32
38
}
33
39
}
34
40
@@ -340,7 +346,7 @@ impl TreeInterface {
340
346
/// Get the parent of node `u`.
341
347
///
342
348
/// Returns `None` if `u` is out of range.
343
- pub fn parent < N : Into < NodeId > + Copy > ( & self , u : N ) -> Option < NodeId > {
349
+ pub fn parent < N : Into < NodeId > + Copy + std :: fmt :: Debug > ( & self , u : N ) -> Option < NodeId > {
344
350
sys:: tsk_column_access :: < NodeId , _ , _ , _ > ( u. into ( ) , self . as_ref ( ) . parent , self . array_len )
345
351
}
346
352
@@ -489,11 +495,8 @@ impl TreeInterface {
489
495
/// (and the tree sequence from which it came).
490
496
///
491
497
/// This is a convenience function for accessing node times, etc..
492
- pub fn node_table ( & self ) -> crate :: NodeTable {
493
- unimplemented ! ( "this needs to return &NodeTable" ) ;
494
- // crate::NodeTable::new_from_table(unsafe {
495
- // &(*(*(*self.as_ptr()).tree_sequence).tables).nodes
496
- // })
498
+ fn node_table ( & self ) -> & crate :: NodeTable {
499
+ & self . nodes
497
500
}
498
501
499
502
/// Calculate the total length of the tree via a preorder traversal.
0 commit comments