Crate tskit

source ·
Expand description

A rust interface to tskit.

This crate provides a mapping of the tskit C API to rust. The result is an interface similar to the tskit Python interface, but with all operations implemented using compiled code.


Interface to the C library


  • The types listed above handle all the memory management!
  • All array accesses are range-checked.
  • Object lifetimes are clear:
    • Creating a tree sequence moves/consumes a table collection.
    • Tree lifetimes are tied to that of the parent tree sequence.
    • Table objects (NodeTable, etc..) are only represented by non-owning, immutable types.


The prelude module contains definitions that are difficult/annoying to live without. In particuar, this module exports various traits that make it so that client code does not have to use them a la carte.

We recomment that client code import all symbols from this module:

use tskit::prelude::*;

The various documentation examples manually use each trait both in order to illustrate which traits are needed and to serve as doc tests.

Optional features

Some features are optional, and are activated by requesting them in your Cargo.toml file.

To add features to your Cargo.toml file:

tskit = {version = "0.2.0", features=["feature0", "feature1"]}

What is missing?

  • A lot of wrappers to the C functions.
  • Tree sequence statistics!



  • Low-level (“unsafe”) bindings to the C API.
  • Error handling
  • Support for table row metadata
  • Export commonly-use types and traits
  • provenanceprovenance
    Optional module for table and tree sequence provenance tables.
  • “Other” tskit types live here.






Type Definitions