/// Verifies if it the state transition is allowed according to the state
/// machine
Verifies if it the state transition is allowed according to the state
machine
Verifies if it the state transition is allowed according to the state machine
fn is_valid_transition(&self, next_state: &Self) -> bool {
        let mut valid = false;
        match self {
            Self::Listening => {
                if let Self::Connected(s) = next_state {
                    if s.role == ConnectionRole::Server {
                        valid = true;
                    }
                }
            }
            Self::Connecting(_) => {
                if let Self::Connected(s) = next_state {
                    if s.role == ConnectionRole::Client {
                        valid = true;
                    }
                }
            }
            Self::Connected(s) => match next_state {
                Self::Listening => {
                    if s.role == ConnectionRole::Server {
                        valid = true;
                    }
                }
                Self::Connecting(_) => {
                    if s.role == ConnectionRole::Client {
                        valid = true;
                    }
                }
                _ => (),
            },
        }
        valid
    }
fn is_valid_transition ( & self , next_state : & Self ) -> bool { let mut valid = false ; match self { Self :: Listening => { if let Self :: Connected ( s ) = next_state { if s . role == ConnectionRole :: Server { valid = true ; } } } Self :: Connecting ( _ ) => { if let Self :: Connected ( s ) = next_state { if s . role == ConnectionRole :: Client { valid = true ; } } } Self :: Connected ( s ) => match next_state { Self :: Listening => { if s . role == ConnectionRole :: Server { valid = true ; } } Self :: Connecting ( _ ) => { if s . role == ConnectionRole :: Client { valid = true ; } } _ => ( ) , } , } valid }
Verifies if it the state transition is allowed according to the state
machine
Verifies if it the state transition is allowed according to the state machine
&self
next_state
&Self