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

A standalone migration table that owns its data.

Examples

use tskit::OwnedMigrationTable;

let mut migrations = OwnedMigrationTable::default();
let rowid = migrations.add_row((0., 1.), 1, (0, 1), 10.3).unwrap();
assert_eq!(rowid, 0);
assert_eq!(migrations.num_rows(), 1);

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

use tskit::OwnedMigrationTable;

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

let metadata = MigrationMetadata{value: 42};

let mut migrations = OwnedMigrationTable::default();

let rowid = migrations.add_row_with_metadata((0., 1.), 1, (0, 1), 10.3, &metadata).unwrap();
assert_eq!(rowid, 0);

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

Implementations

Clear the table.

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

Return the number of rows

Return the left coordinate for a given row.

Errors

Return the right coordinate for a given row.

Errors

Return the node for a given row.

Errors

Return the source population for a given row.

Errors

Return the destination population for a given row.

Errors

Return the time of the migration event for a given row.

Errors

Return the metadata for a given row.

Errors

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

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.