use s2n_quic_core::{endpoint, state::event};
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum State {
ClientInit,
ClientQueueIdObserved,
ServerInit,
ServerQueueIdObserved,
Finished,
}
impl State {
event! {
on_stream_packet(ClientInit => ClientQueueIdObserved);
on_control_packet(ClientInit => ClientQueueIdObserved, ServerInit => ServerQueueIdObserved);
on_non_zero_next_expected_control_packet(ServerInit => ServerQueueIdObserved);
on_observation_finished(ClientQueueIdObserved | ServerQueueIdObserved => Finished);
}
}
impl From<endpoint::Type> for State {
#[inline]
fn from(value: endpoint::Type) -> Self {
match value {
endpoint::Type::Client => Self::ClientInit,
endpoint::Type::Server => Self::ServerInit,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use insta::{assert_debug_snapshot, assert_snapshot};
#[test]
#[cfg_attr(miri, ignore)]
fn snapshots() {
assert_debug_snapshot!(State::test_transitions());
}
#[test]
#[cfg_attr(miri, ignore)]
fn dot_test() {
assert_snapshot!(State::dot());
}
}