Skip to main content

ts_bart/
lib.rs

1#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))]
2#![no_std]
3
4extern crate alloc;
5#[cfg(test)]
6extern crate std;
7
8mod allot;
9mod base_index;
10pub mod iptrie;
11mod lpm;
12mod node;
13pub mod table;
14#[cfg(test)]
15pub mod test_util;
16
17pub use allot::{fringe as allot_fringe, prefix as allot_prefix};
18pub use base_index::BaseIndex;
19#[doc(inline)]
20pub use iptrie::RouteModification;
21pub use lpm::lookup as lpm;
22pub use node::{
23    BoxStorage, Child, DefaultNode, DefaultStorage, InlineStorage, Node, PrefixOps, PrefixOpsExt,
24    PrefixReadOps, Stats, Storage, StrideBase, StrideOps, StrideOpsExt,
25};
26#[doc(inline)]
27pub use table::{RoutingTable, RoutingTableExt};
28
29/// Total memory usage of all lookup tables in the crate.
30#[cfg(feature = "lut")]
31pub const LUT_MEMORY: usize = allot::LUT_SIZE + ts_bitset::RANK_LUT_SIZE + lpm::LUT_SIZE;
32
33/// General-purpose table type.
34///
35/// Type alias around [`table::SplitStackTable`] that specializes the node type
36/// to canonical [`Node`] with boxed child storage ([`BoxStorage`]).
37/// The type parameter is the contained route value type.
38pub type Table<T> = table::SplitStackTable<DefaultNode<T>>;
39
40/// Table for single-IP-stack environments.
41///
42/// Type alias around [`table::SimpleTable`] that specializes the node type to
43/// the canonical [`Node`] with boxed child storage
44/// ([`BoxStorage`]). The type parameter is the contained route value type.
45pub type SimpleTable<T> = table::SimpleTable<DefaultNode<T>>;
46
47#[cfg(test)]
48mod test {
49    #[cfg(feature = "lut")]
50    #[test]
51    fn lut_size() {
52        std::println!("LUT memory usage: {}B", super::LUT_MEMORY);
53
54        assert_eq!(
55            super::LUT_MEMORY,
56            32 * 1024,
57            "lut memory usage changed, please update the test if this was intentional",
58        );
59    }
60}