@@ -2,6 +2,7 @@ use crate::bindings as ll_bindings;
22use crate :: metadata;
33use crate :: { tsk_id_t, tsk_size_t, TskitError } ;
44
5+ /// Row of an [`EdgeTable`]
56pub struct EdgeTableRow {
67 pub left : f64 ,
78 pub right : f64 ,
@@ -10,6 +11,16 @@ pub struct EdgeTableRow {
1011 pub metadata : Option < Vec < u8 > > ,
1112}
1213
14+ impl PartialEq for EdgeTableRow {
15+ fn eq ( & self , other : & Self ) -> bool {
16+ self . parent == other. parent
17+ && self . child == other. child
18+ && crate :: util:: f64_partial_cmp_equal ( & self . left , & other. left )
19+ && crate :: util:: f64_partial_cmp_equal ( & self . right , & other. right )
20+ && crate :: util:: metadata_like_are_equal ( & self . metadata , & other. metadata )
21+ }
22+ }
23+
1324fn make_edge_table_row (
1425 table : & EdgeTable ,
1526 pos : tsk_id_t ,
@@ -138,4 +149,21 @@ impl<'a> EdgeTable<'a> {
138149 pub fn iter ( & self , decode_metadata : bool ) -> EdgeTableRefIterator {
139150 crate :: table_iterator:: make_table_iterator :: < & EdgeTable < ' a > > ( & self , decode_metadata)
140151 }
152+
153+ /// Return row `r` of the table.
154+ ///
155+ /// # Parameters
156+ ///
157+ /// * `r`: the row id.
158+ /// * `decode_metadata`: if `true`, then a *copy* of row metadata
159+ /// will be provided in [`EdgeTableRow::metadata`].
160+ /// The meta data are *not* decoded.
161+ /// Rows with no metadata will contain the value `None`.
162+ ///
163+ /// # Errors
164+ ///
165+ /// [`TskitError::IndexError`] if `r` is out of range.
166+ pub fn row ( & self , r : tsk_id_t , decode_metadata : bool ) -> Result < EdgeTableRow , TskitError > {
167+ table_row_access ! ( r, decode_metadata, self , make_edge_table_row)
168+ }
141169}
0 commit comments