alma 0.1.1

A Bevy-native modal text editor with Vim-style navigation.
Documentation
//! Editor command request messages.

use crate::ecs::components::buffer::{BufferEntity, ViewEntity};
use crate::vim::{VimCommand, VimError};
use bevy::prelude::Message;

pub use super::error::CommandRejectionReason;
pub use super::operation::{
    OperationFailureClass as CommandFailureClass, OperationFailureSource as CommandFailureSource,
    OperationRetryAdvice as CommandRetryAdvice,
};

/// Request to execute a parsed editor command at the owner boundary.
#[derive(Clone, Copy, Debug, Eq, Message, PartialEq)]
pub struct CommandRequested {
    /// Editor buffer entity that owns text and persistence.
    pub target: BufferEntity,
    /// Editor view that submitted the command and should receive status.
    pub source: ViewEntity,
    /// Parsed command submitted by an input interpreter.
    pub command: VimCommand,
}

/// Notification that a command request could not be resolved at the owner boundary.
#[derive(Clone, Copy, Debug, Eq, Message, PartialEq)]
pub struct CommandRejected {
    /// Editor buffer entity that was requested.
    pub target: BufferEntity,
    /// Editor view that submitted the command.
    pub source: ViewEntity,
    /// Parsed command that could not be applied.
    pub command: VimCommand,
    /// Typed rejection reason.
    pub reason: CommandRejectionReason,
}

/// Notification that a resolved command failed during execution.
#[derive(Clone, Copy, Debug, Eq, Message, PartialEq)]
pub struct CommandFailed {
    /// Editor buffer entity that owned command execution.
    pub target: BufferEntity,
    /// Editor view that submitted the command.
    pub source: ViewEntity,
    /// Parsed command that failed.
    pub command: VimCommand,
    /// Redacted diagnostic shape for production telemetry.
    pub diagnostic: CommandFailureDiagnostic,
}

/// Redacted command failure shape safe to carry across diagnostic boundaries.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct CommandFailureDiagnostic {
    /// Coarse failure class.
    pub class: CommandFailureClass,
    /// Stable Vim-facing status error.
    pub status_error: VimError,
    /// Optional redacted lower-boundary source shape.
    pub source: Option<CommandFailureSource>,
    /// Retry guidance for the same command request.
    pub retry: CommandRetryAdvice,
}