mecha10-behavior-runtime 0.8.1

Behavior tree runtime for Mecha10 - unified AI and logic composition system
Documentation
//! Node status types for behavior execution
//!
//! This module defines the possible states a behavior node can be in during execution.

use serde::{Deserialize, Serialize};
use std::fmt;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
pub enum NodeStatus {
    Success,

    Failure,

    #[default]
    Running,
}

impl NodeStatus {
    /// Returns true if the status indicates completion (Success or Failure).
    pub fn is_complete(&self) -> bool {
        matches!(self, NodeStatus::Success | NodeStatus::Failure)
    }

    /// Returns true if the status is Success.
    pub fn is_success(&self) -> bool {
        matches!(self, NodeStatus::Success)
    }

    /// Returns true if the status is Failure.
    pub fn is_failure(&self) -> bool {
        matches!(self, NodeStatus::Failure)
    }

    /// Returns true if the status is Running.
    pub fn is_running(&self) -> bool {
        matches!(self, NodeStatus::Running)
    }
}

impl fmt::Display for NodeStatus {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            NodeStatus::Success => write!(f, "Success"),
            NodeStatus::Failure => write!(f, "Failure"),
            NodeStatus::Running => write!(f, "Running"),
        }
    }
}