Skip to main content

dope_sys/io/socket/route/
plan.rs

1use std::mem;
2
3use crate::io::socket::route::{
4    count::Count,
5    selector::{PrefixPlan, Selector},
6};
7
8/// A selector bound to the dense routing domain it selects from.
9#[derive(Clone, Copy, Debug, Eq, PartialEq)]
10pub struct Plan {
11    count: Count,
12    selector: Selector,
13    prefix: Option<PrefixPlan>,
14}
15
16impl Plan {
17    pub const fn new(count: Count, selector: Selector) -> Self {
18        Self {
19            count,
20            selector,
21            prefix: None,
22        }
23    }
24
25    pub const fn with_prefix(self, prefix: PrefixPlan) -> Self {
26        Self {
27            prefix: Some(prefix),
28            ..self
29        }
30    }
31
32    pub const fn count(self) -> Count {
33        self.count
34    }
35
36    pub const fn selector(self) -> Selector {
37        self.selector
38    }
39
40    pub const fn prefix(self) -> Option<PrefixPlan> {
41        self.prefix
42    }
43}
44
45const _: () = {
46    assert!(
47        mem::size_of::<Plan>()
48            == mem::size_of::<Count>()
49                + mem::size_of::<Selector>()
50                + mem::size_of::<Option<PrefixPlan>>()
51    );
52};