Skip to content

Commit 95c4a45

Browse files
committed
all the tables
1 parent d9bf823 commit 95c4a45

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/provenance.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
//! [`ProvenanceTable::iter`].
1111
//!
1212
13-
use std::ptr::NonNull;
14-
1513
use crate::bindings as ll_bindings;
1614
use crate::sys;
1715
use crate::SizeType;
@@ -141,23 +139,19 @@ impl<'a> streaming_iterator::StreamingIterator for ProvenanceTableRowView<'a> {
141139
///
142140
#[derive(Debug)]
143141
pub struct ProvenanceTable {
144-
table_: NonNull<ll_bindings::tsk_provenance_table_t>,
142+
table_: sys::LLProvenanceTableRef,
145143
}
146144

147145
impl ProvenanceTable {
148146
pub(crate) fn new_from_table(
149147
provenances: *mut ll_bindings::tsk_provenance_table_t,
150148
) -> Result<Self, crate::TskitError> {
151-
// FIXME: unwrap
152-
let n = NonNull::new(provenances).ok_or_else(|| {
153-
crate::TskitError::LibraryError("null pointer to tsk_provenance_table_t".to_string())
154-
})?;
155-
Ok(ProvenanceTable { table_: n })
149+
let table_ = sys::LLProvenanceTableRef::new_from_table(provenances)?;
150+
Ok(ProvenanceTable { table_ })
156151
}
157152

158153
pub(crate) fn as_ref(&self) -> &ll_bindings::tsk_provenance_table_t {
159-
// SAFETY: NonNull
160-
unsafe { self.table_.as_ref() }
154+
self.table_.as_ref()
161155
}
162156

163157
/// Return the number of rows

src/sys.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ use bindings::tsk_population_table_t;
88
use bindings::tsk_site_table_t;
99
use std::ptr::NonNull;
1010

11+
#[cfg(feature = "provenance")]
12+
use bindings::tsk_provenance_table_t;
13+
1114
macro_rules! basic_lltableref_impl {
1215
($lltable: ident, $tsktable: ident) => {
1316
#[repr(transparent)]
@@ -41,6 +44,9 @@ basic_lltableref_impl!(LLMigrationTableRef, tsk_migration_table_t);
4144
basic_lltableref_impl!(LLPopulationTableRef, tsk_population_table_t);
4245
basic_lltableref_impl!(LLIndividualTableRef, tsk_individual_table_t);
4346

47+
#[cfg(feature = "provenance")]
48+
basic_lltableref_impl!(LLProvenanceTableRef, tsk_provenance_table_t);
49+
4450
fn tsk_column_access_detail<R: Into<bindings::tsk_id_t>, L: Into<bindings::tsk_size_t>, T: Copy>(
4551
row: R,
4652
column: *const T,

0 commit comments

Comments
 (0)