(self, new_state: VmState)
| 407 | |
| 408 | impl VmState { |
| 409 | fn valid_transition(self, new_state: VmState) -> Result<()> { |
| 410 | match self { |
| 411 | VmState::Created => match new_state { |
| 412 | VmState::Created => Err(Error::InvalidStateTransition(self, new_state)), |
| 413 | VmState::Running | VmState::Paused | VmState::BreakPoint | VmState::Shutdown => { |
| 414 | Ok(()) |
| 415 | } |
| 416 | }, |
| 417 | |
| 418 | VmState::Running => match new_state { |
| 419 | VmState::Created | VmState::Running => { |
| 420 | Err(Error::InvalidStateTransition(self, new_state)) |
| 421 | } |
| 422 | VmState::Paused | VmState::Shutdown | VmState::BreakPoint => Ok(()), |
| 423 | }, |
| 424 | |
| 425 | VmState::Shutdown => match new_state { |
| 426 | VmState::Paused | VmState::Created | VmState::Shutdown | VmState::BreakPoint => { |
| 427 | Err(Error::InvalidStateTransition(self, new_state)) |
| 428 | } |
| 429 | VmState::Running => Ok(()), |
| 430 | }, |
| 431 | |
| 432 | VmState::Paused => match new_state { |
| 433 | VmState::Created | VmState::Paused | VmState::BreakPoint => { |
| 434 | Err(Error::InvalidStateTransition(self, new_state)) |
| 435 | } |
| 436 | VmState::Running | VmState::Shutdown => Ok(()), |
| 437 | }, |
| 438 | VmState::BreakPoint => match new_state { |
| 439 | VmState::Created | VmState::Running => Ok(()), |
| 440 | _ => Err(Error::InvalidStateTransition(self, new_state)), |
| 441 | }, |
| 442 | } |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | struct VmOpsHandler { |
no outgoing calls