1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
mod ids;
mod net;
mod state;
mod streams;
mod utils;

pub use ids::{Pid, Tid};
pub use state::StateInitializationError;

use crate::sys::types::Node;

impl<Id> Node<Id> {
    /// Get a slice of indices to the next nodes.
    pub fn next(&self) -> &[Id] {
        if self.next_count == 0 {
            &[]
        } else {
            unsafe { std::slice::from_raw_parts(self.next, self.next_count) }
        }
    }

    /// Get a slice of indices to the previous nodes.
    pub fn prev(&self) -> &[Id] {
        if self.prev_count == 0 {
            &[]
        } else {
            unsafe { std::slice::from_raw_parts(self.prev, self.prev_count) }
        }
    }
}