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

A standalone mutation table that owns its data.

Examples

use tskit::OwnedMutationTable;

let mut mutations = OwnedMutationTable::default();
let rowid = mutations.add_row(1, 2, 0, 1.0, None).unwrap();
assert_eq!(rowid, 0);
assert_eq!(mutations.num_rows(), 1);

An example with metadata. This requires the cargo feature "derive" for tskit.

use tskit::OwnedMutationTable;

#[derive(serde::Serialize,
         serde::Deserialize,
         tskit::metadata::MutationMetadata)]
#[serializer("serde_json")]
struct MutationMetadata {
    value: i32,
}

let metadata = MutationMetadata{value: 42};

let mut mutations = OwnedMutationTable::default();

let rowid = mutations.add_row_with_metadata(0, 1, 5, 10.0, None, &metadata).unwrap();
assert_eq!(rowid, 0);

if let Some(decoded) = mutations.metadata::<MutationMetadata>(rowid).unwrap() {
    assert_eq!(decoded.value, 42);
} else {
    panic!("hmm...we expected some metadata!");
}

Implementations

Clear the table.

Methods from Deref<Target = MutationTable<'static>>

Return the number of rows.

Return the site value from row row of the table.

Errors

Will return IndexError if row is out of range.

Return the node value from row row of the table.

Errors

Will return IndexError if row is out of range.

Return the parent value from row row of the table.

Errors

Will return IndexError if row is out of range.

Return the time value from row row of the table.

Errors

Will return IndexError if row is out of range.

Get the derived_state value from row row of the table.

Return

Will return None if there is no derived state.

Errors

Will return IndexError if row is out of range.

Return an iterator over rows of the table. The value of the iterator is MutationTableRow.

Return row r of the table.

Parameters
  • r: the row id.
Errors

TskitError::IndexError if r is out of range.

Trait Implementations

Returns the “default value” for a type. Read more
The resulting type after dereferencing.
Dereferences the value.
Executes the destructor for this type. Read more

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
Drops the content pointed by this pointer and frees it. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.