You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* We assume familiarity with `tskit`. See [tskit.dev](https://tskit.dev).
6
+
* Comfort with rust is required.
7
+
*[The book](https://doc.rust-lang.org/book/) is a good place to start.
8
+
*[The Rustonomicon](https://doc.rust-lang.org/nomicon/) is for those who wish to dig deeper into `unsafe` rust and FFI.
9
+
The 'nomicon is helpful for understanding how things like the `tskit` rust API can be built in the first place.
10
+
11
+
## Conventions used in this document
12
+
13
+
Here, `tskit` means the rust API.
14
+
`tskit-c` and `tskit-python` refer to the C and Python APIs, respectively.
15
+
16
+
The phrase "data model" refers to [this](https://tskit.dev/tskit/docs/stable/data-model.html). This document will make little sense without an understanding of the data model.
17
+
18
+
## Relation to the C API
19
+
20
+
Where necessary, we will note differences from the behavior of `tskit-c`.
21
+
22
+
Much of the rust API works by calling the C API.
23
+
We do not change the semantics of the C API.
24
+
However, we do make stricter statements about the ownership relationships between types.
25
+
For example, the C API can result in the following situation:
26
+
27
+
* A heap-allocated table collection is used to record data about the ancestry of a sample.
28
+
* That table collection is used to initialize a tree sequence.
29
+
The tree sequence is told to take ownership of the tables.
30
+
31
+
This is a case where the C API requires that you respectfully no longer work with the heap-allocated table collection. To do so is undefined behavior.
32
+
33
+
The rust API forbids such situations.
34
+
The creation of a tree sequence from tables consumes the tables via a move operation.
35
+
Thus, any further actions on the tables is a compiler error.
36
+
37
+
This example is the kinds of differences between `tskit` and `tskit-c`.
38
+
Undefined behavior is (close to) impossible with `tskit`.
39
+
40
+
41
+
## Quick overview
42
+
43
+
### Do you need `tskit-rust`?
4
44
5
45
The use-cases for `tskit-rust` are the same as for `tskit-c`:
6
46
7
47
1. Developing a new performance-oriented application.
8
48
2. The input/output of this application will be a `.trees` file.
9
49
10
-
## What does `tskit-rust` add?
50
+
###What does `tskit-rust` add?
11
51
12
52
Briefly, you get the performance of `C` and the strong safety guarantees of `rust`.
13
53
14
-
## What is `tskit-rust` missing?
54
+
###What is `tskit-rust` missing?
15
55
16
56
The crate does not cover the entire `C` API.
17
57
However, client code can make direct calls to that API via the module `tskit::bindings`.
18
58
19
-
## Adding `tskit` as a dependency to a rust project
59
+
###Adding `tskit` as a dependency to a rust project
20
60
21
61
In your `Cargo.toml`:
22
62
@@ -28,15 +68,8 @@ tskit = "~X.Y.Z"
28
68
The latest version to fill in `X.Y.Z` can be found [here](https://crates.io/crates/tskit).
29
69
See [here](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html) for how to specify version numbers.
30
70
31
-
### Feature flags.
71
+
####Feature flags.
32
72
33
73
`tskit` defines several [cargo features](https://doc.rust-lang.org/cargo/reference/features.html).
34
74
These are defined in the [API docs](https://docs.rs/tskit/latest/tskit/#optional-features).
35
75
36
-
## Conventions used in this document
37
-
38
-
We assume a working knowledge of rust.
39
-
Thus, we skip over the details of things like matching idioms, etc.,
40
-
and just `.unwrap()`.
41
-
42
-
We also assume familiarity with the `tskit`[data model](https://tskit.dev/tskit/docs/stable/data-model.html).
0 commit comments