Skip to content

Commit 4634a8a

Browse files
committed
more
1 parent 489509a commit 4634a8a

File tree

2 files changed

+16
-27
lines changed

2 files changed

+16
-27
lines changed

src/edge_table.rs

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,7 @@ impl EdgeTable {
233233
/// * `Some(child)` if `u` is valid.
234234
/// * `None` otherwise.
235235
pub fn child<E: Into<EdgeId> + Copy>(&self, row: E) -> Option<NodeId> {
236-
assert!(self.num_rows() == 0 || !self.as_ref().child.is_null());
237-
// SAFETY: either the column is empty or the point is not NULL
238-
unsafe {
239-
sys::tsk_column_access::<NodeId, _, _, _>(
240-
row.into(),
241-
self.as_ref().child,
242-
self.num_rows(),
243-
)
244-
}
236+
self.table_.child(row.into())
245237
}
246238

247239
/// Return the ``left`` value from row ``row`` of the table.
@@ -251,15 +243,7 @@ impl EdgeTable {
251243
/// * `Some(position)` if `u` is valid.
252244
/// * `None` otherwise.
253245
pub fn left<E: Into<EdgeId> + Copy>(&self, row: E) -> Option<Position> {
254-
assert!(self.num_rows() == 0 || !self.as_ref().left.is_null());
255-
// SAFETY: either the column is empty or the point is not NULL
256-
unsafe {
257-
sys::tsk_column_access::<Position, _, _, _>(
258-
row.into(),
259-
self.as_ref().left,
260-
self.num_rows(),
261-
)
262-
}
246+
self.table_.left(row.into())
263247
}
264248

265249
/// Return the ``right`` value from row ``row`` of the table.
@@ -269,15 +253,7 @@ impl EdgeTable {
269253
/// * `Some(position)` if `u` is valid.
270254
/// * `None` otherwise.
271255
pub fn right<E: Into<EdgeId> + Copy>(&self, row: E) -> Option<Position> {
272-
assert!(self.num_rows() == 0 || !self.as_ref().right.is_null());
273-
// SAFETY: either the column is empty or the point is not NULL
274-
unsafe {
275-
sys::tsk_column_access::<Position, _, _, _>(
276-
row.into(),
277-
self.as_ref().right,
278-
self.num_rows(),
279-
)
280-
}
256+
self.table_.left(row.into())
281257
}
282258

283259
/// Retrieve decoded metadata for a `row`.

src/sys/edge_table.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::ptr::NonNull;
22

33
use super::newtypes::EdgeId;
44
use super::newtypes::NodeId;
5+
use super::newtypes::Position;
56

67
use super::bindings::tsk_edge_table_add_row;
78
use super::bindings::tsk_edge_table_clear;
@@ -72,6 +73,18 @@ impl EdgeTable {
7273
pub fn parent(&self, row: EdgeId) -> Option<NodeId> {
7374
safe_tsk_column_access!(self, row, NodeId, parent)
7475
}
76+
77+
pub fn child(&self, row: EdgeId) -> Option<NodeId> {
78+
safe_tsk_column_access!(self, row, NodeId, child)
79+
}
80+
81+
pub fn left(&self, row: EdgeId) -> Option<Position> {
82+
safe_tsk_column_access!(self, row, Position, left)
83+
}
84+
85+
pub fn right(&self, row: EdgeId) -> Option<Position> {
86+
safe_tsk_column_access!(self, row, Position, right)
87+
}
7588
}
7689

7790
impl Default for EdgeTable {

0 commit comments

Comments
 (0)