antenna_protocol/handshake/
strategy.rs1use serde::{Deserialize, Serialize};
2
3use crate::{HandshakeInput, HandshakeOutput, HandshakeState, Host, Joiner};
4use anyhow::Result;
5
6#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
12pub enum HandshakeStrategy {
13 Host,
15 Joiner,
17}
18
19pub enum StrategyFSM {
20 Host(Host),
21 Joiner(Joiner),
22}
23
24impl StrategyFSM {
25 pub fn state(&self) -> &HandshakeState {
26 match self {
27 Self::Host(host) => host.state(),
28 Self::Joiner(joiner) => joiner.state(),
29 }
30 }
31
32 pub fn process(&mut self, input: HandshakeInput) -> Result<Option<HandshakeOutput>> {
33 match self {
34 Self::Host(host) => host.process(input),
35 Self::Joiner(joiner) => joiner.process(input),
36 }
37 }
38}