helm-rs 0.1.1

Typed Rust API for Helm 4: swappable backends, native chart, values and release reading
Documentation
//! The token and comment types of the scanner (`yamlh.go`).

use super::Mark;

/// The kinds of token.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(super) enum TokenType {
    StreamStart,
    StreamEnd,
    VersionDirective,
    TagDirective,
    DocumentStart,
    DocumentEnd,
    BlockSequenceStart,
    BlockMappingStart,
    BlockEnd,
    FlowSequenceStart,
    FlowSequenceEnd,
    FlowMappingStart,
    FlowMappingEnd,
    BlockEntry,
    FlowEntry,
    Key,
    Value,
    Alias,
    Anchor,
    Tag,
    Scalar,
}

/// How a scalar was written.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub(super) enum ScalarStyle {
    #[default]
    Plain,
    Single,
    Double,
    Literal,
    Folded,
}

/// A token.
#[derive(Debug, Clone)]
pub(super) struct Token {
    pub(super) typ: TokenType,
    pub(super) start_mark: Mark,
    pub(super) end_mark: Mark,
    pub(super) value: Vec<u8>,
    pub(super) suffix: Vec<u8>,
    pub(super) prefix: Vec<u8>,
    pub(super) style: ScalarStyle,
    pub(super) major: i8,
    pub(super) minor: i8,
}

impl Token {
    pub(super) fn new(typ: TokenType, start_mark: Mark, end_mark: Mark) -> Self {
        Self {
            typ,
            start_mark,
            end_mark,
            value: Vec::new(),
            suffix: Vec::new(),
            prefix: Vec::new(),
            style: ScalarStyle::Plain,
            major: 0,
            minor: 0,
        }
    }
}

/// A comment waiting to be handed to the token it belongs to (`yaml_comment_t`).
#[derive(Debug, Clone, Default)]
pub(super) struct Comment {
    pub(super) scan_mark: Mark,
    pub(super) token_mark: Mark,
    pub(super) start_mark: Mark,
    pub(super) end_mark: Mark,
    pub(super) head: Vec<u8>,
    pub(super) line: Vec<u8>,
    pub(super) foot: Vec<u8>,
}

/// A place where a simple (single-line) key may start (`yaml_simple_key_t`).
#[derive(Debug, Clone, Copy, Default)]
pub(super) struct SimpleKey {
    pub(super) possible: bool,
    pub(super) required: bool,
    pub(super) token_number: usize,
    pub(super) mark: Mark,
}