alma 0.1.1

A Bevy-native modal text editor with Vim-style navigation.
Documentation
//! Closed field vocabulary for guest decode diagnostics.

use std::fmt::{Debug, Display, Formatter};

/// Guest-owned field names that can appear in decode diagnostics.
#[derive(Clone, Copy, Eq, PartialEq)]
pub enum GuestDecodeField {
    /// `status-publish` text payload.
    StatusText,
    /// Capability name payload.
    Capability,
    /// Unexpected `buffer.observe` path payload.
    BufferObservePath,
    /// Buffer edit byte index.
    BufferEditByteIndex,
    /// Buffer edit byte range.
    BufferEditRange,
    /// Buffer edit text payload.
    BufferEditText,
    /// Unexpected `buffer.propose_edit` path payload.
    BufferProposeEditPath,
    /// `workspace.observe` path payload.
    WorkspaceObservePath,
    /// `workspace.artifact_write` path payload.
    WorkspaceArtifactWritePath,
    /// `workspace.artifact_write` bytes payload.
    WorkspaceArtifactWriteBytes,
    /// Unexpected `status.publish` path payload.
    StatusPublishPath,
}

impl GuestDecodeField {
    /// Stable field name used in diagnostics.
    #[must_use]
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::StatusText => "status.text",
            Self::Capability => "capability",
            Self::BufferObservePath => "buffer.observe.path",
            Self::BufferEditByteIndex => "buffer.edit.byte_index",
            Self::BufferEditRange => "buffer.edit.range",
            Self::BufferEditText => "buffer.edit.text",
            Self::BufferProposeEditPath => "buffer.propose_edit.path",
            Self::WorkspaceObservePath => "workspace.observe.path",
            Self::WorkspaceArtifactWritePath => "workspace.artifact_write.path",
            Self::WorkspaceArtifactWriteBytes => "workspace.artifact_write.bytes",
            Self::StatusPublishPath => "status.publish.path",
        }
    }
}

impl Display for GuestDecodeField {
    fn fmt(&self, formatter: &mut Formatter<'_>) -> std::fmt::Result {
        formatter.write_str(self.as_str())
    }
}

impl Debug for GuestDecodeField {
    fn fmt(&self, formatter: &mut Formatter<'_>) -> std::fmt::Result {
        formatter.write_str(self.as_str())
    }
}