lichtung-plot 0.2.0

Strongly typed scientific plotting with deterministic SVG and PNG output
Documentation
//! Actual independently supplied facet member variables.

use crate::data::KeyValues;

/// The original per-result facet variables, preserving their separate fields.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum FacetBinding {
    /// One actual facet field.
    Wrap(KeyValues),
    /// Two actual crossed facet fields.
    Grid {
        /// Original row field.
        row: KeyValues,
        /// Original column field.
        column: KeyValues,
    },
}

impl FacetBinding {
    /// Original single-dimensional field, if supplied.
    pub fn get_wrap(&self) -> Option<&KeyValues> {
        match self {
            Self::Wrap(values) => Some(values),
            Self::Grid { .. } => None,
        }
    }

    /// Original crossed fields, if supplied.
    pub fn get_grid(&self) -> Option<(&KeyValues, &KeyValues)> {
        match self {
            Self::Grid { row, column } => Some((row, column)),
            Self::Wrap(_) => None,
        }
    }
}