sokoban-elements 0.2.1

Parsing and writing Sokoban, Hexoban, Trioban and Octoban file formats.
Documentation
use super::FileFormat;

/// Settings for [`FileFormat`] writer.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(
    feature = "serde",
    derive(serde::Serialize, serde::Deserialize),
    serde(default)
)]
pub struct WriterSettings {
    pub file_format: FileFormat,

    /// Depending on this, printed game boards will use `-` (dash) to represent empty floors. This
    /// is arguably more visible than default ` ` (space).
    ///
    /// This is most helpful for debugging sessions, otherwise really makes no difference.
    ///
    /// Textual representation of Hexoban boards is highly sensitive to whitespace. For that reason
    /// this option is always ignored for Hexoban boards. When writing Hexoban boards, they always
    /// behave as if this option was `true`.
    pub print_visible_floor: bool,

    /// Some file formats support RLE compressed game boards and saved games. Where applicable, use
    /// `true` to produce this kind of output.
    pub rle_encode: bool,

    pub wrap_savegame_lines_at: u8,
}

impl Default for WriterSettings {
    fn default() -> Self {
        Self {
            file_format:            FileFormat::SokobanYASC,
            print_visible_floor:    false,
            rle_encode:             false,
            wrap_savegame_lines_at: 70,
        }
    }
}

/// Settings for [`FileFormat`] reader.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(
    feature = "serde",
    derive(serde::Serialize, serde::Deserialize),
    serde(default)
)]
pub struct ReaderSettings {
    pub file_format: FileFormat,

    /// See [`SokobanPlus::parsed_legacy()`](crate::SokobanPlus::parsed_legacy()) to understand
    /// this flag.
    pub legacy_sokoban_plus: bool,
}

impl Default for ReaderSettings {
    fn default() -> Self {
        Self {
            file_format:         FileFormat::SokobanYASC,
            legacy_sokoban_plus: false,
        }
    }
}