pub struct DispatchableNetwork { /* private fields */ }Expand description
A dispatchable network produced on the ground, ready to load into a Dispatcher.
Produced by Stn::dispatchable and
Stnu::dispatchable. Point indices match the source network.
Implementations§
Source§impl DispatchableNetwork
impl DispatchableNetwork
Sourcepub fn edges(&self) -> &[DispatchEdge]
pub fn edges(&self) -> &[DispatchEdge]
Dispatchable edges.
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
Adjacency entries a Dispatcher needs: two per edge plus one per wait.
Sourcepub fn dispatcher<const N: usize, const E: usize, I: Index>(
&self,
) -> Result<Dispatcher<N, E, I>, DispatchError>
pub fn dispatcher<const N: usize, const E: usize, I: Index>( &self, ) -> Result<Dispatcher<N, E, I>, DispatchError>
Loads this network into a new fixed-capacity dispatcher.
The index type I is usually inferred from the annotated result type, e.g.
let d: Dispatcher<8, 64> = net.dispatcher()? (with the default usize) or
Dispatcher<8, 64, u16>. To load into an existing dispatcher in place, use
Dispatcher::load with Self::points, Self::edges and Self::waits.
§Errors
As for Dispatcher::load.
Sourcepub fn encode(&self) -> Result<Vec<u8>, EncodeError>
pub fn encode(&self) -> Result<Vec<u8>, EncodeError>
Encodes this network in the compact checksummed format of encoding.
§Examples
use temporal_control::{Budget, Dispatcher, DispatchableNetwork, Stn, Ticks, Verdict};
let mut stn = Stn::new();
let a = stn.add_time_point().expect("fits");
let b = stn.add_time_point().expect("fits");
stn.add_constraint(a, b, Some(Ticks(5)), Some(Ticks(15))).expect("exists");
let Verdict::Consistent(net) = stn.dispatchable(&Budget::UNLIMITED).expect("fits") else {
panic!("consistent");
};
let bytes = net.encode().expect("small");
assert_eq!(DispatchableNetwork::decode(&bytes), Ok(net));
let mut d = Dispatcher::<2, 8>::EMPTY;
d.load_encoded(&bytes).expect("valid");§Errors
EncodeError::TooLarge if a count or index exceeds u32::MAX.
Sourcepub fn decode(bytes: &[u8]) -> Result<Self, DecodeError>
pub fn decode(bytes: &[u8]) -> Result<Self, DecodeError>
Decodes and validates an encoding, for ground-side checks of what will be uplinked.
Accepts exactly the encodings that a dispatcher of unlimited capacity with usize
indices accepts.
§Errors
As for Dispatcher::load_encoded, except that capacities never apply.