demes_forward/
lib.rs

1//! # Forward-time traversal of demes models.
2//!
3//! ## Re-exports
4//!
5//! This crate re-exports `demes`.
6//! Client code does not have to list `demes`
7//! as a cargo dependency, guaranteeing that
8//! a compatible version is available.
9//!
10//! ```{rust}
11//! use demes_forward::demes;
12//!
13//! let yaml = "
14//! time_units: generations
15//! demes:
16//!  - name: a_deme
17//!    epochs:
18//!     - start_size: 100
19//! ";
20//! assert!(demes::loads(yaml).is_ok());
21//! ```
22
23#![warn(missing_docs)]
24#![warn(rustdoc::broken_intra_doc_links)]
25
26mod current_size;
27mod error;
28mod graph;
29mod iterators;
30mod square_matrix;
31mod time;
32
33pub use current_size::CurrentSize;
34pub use demes;
35pub use error::DemesForwardError;
36pub use graph::ForwardGraph;
37pub use time::ForwardTime;
38
39/// The size of a deme at a given time.
40#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
41pub struct DemeSizeAt {
42    time: demes::Time,
43    forward_time: ForwardTime,
44    size: CurrentSize,
45}
46
47impl DemeSizeAt {
48    /// The current time (in the past)
49    pub fn time(&self) -> demes::Time {
50        self.time
51    }
52    /// The current time measured since the
53    /// start of the model, forwards in time
54    pub fn forward_time(&self) -> ForwardTime {
55        self.forward_time
56    }
57    /// The current size
58    pub fn size(&self) -> CurrentSize {
59        self.size
60    }
61}