tudelft-xray-sim 1.0.1

simulation library for the modeling assignment in the course 'Software Systems' at the TU Delft.
Documentation
#[allow(unused_imports)]
use crate::{ActionLogic, PedalMapper};
use crate::{Dose, Mode, Projection};

#[allow(missing_docs)]
/// Request sent from [`PedalMapper`] to [`ActionLogic`].
///
/// `PedalMapper` figures out which pedal press or release corresponds to what kind of request.
/// `ActionLogic` then handles this request.
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum Request {
    /// Start the X-ray with the given projection, dose, and mode.
    Start {
        projection: Projection,
        dose: Dose,
        mode: Mode,
    },
    /// Stop the X-ray with the given projection, dose, and mode.
    Stop {
        projection: Projection,
        dose: Dose,
        mode: Mode,
    },
    /// Sent when the selected projection should be toggled.
    ToggleSelectedProjection,
    /// Start the X-ray with the currently selected projection and the given dose and mode.
    StartSelectedProjection { dose: Dose, mode: Mode },
    /// Stop the X-ray with the selected projection and this dose and mode.
    StopSelectedProjection { dose: Dose, mode: Mode },
}

impl Request {
    /// Create a `Request::Start`.
    #[must_use]
    pub fn start(projection: Projection, dose: Dose, mode: Mode) -> Self {
        Self::Start {
            projection,
            dose,
            mode,
        }
    }

    /// Create a `Request::Stop`.
    #[must_use]
    pub fn stop(projection: Projection, dose: Dose, mode: Mode) -> Self {
        Self::Stop {
            projection,
            dose,
            mode,
        }
    }

    /// Create a `Request::ToggleSelectedProjection`.
    #[must_use]
    pub fn toggle_selected_projection() -> Self {
        Self::ToggleSelectedProjection
    }

    /// Create a `Request::StartSelectedProjection`.
    #[must_use]
    pub fn start_selected_projection(dose: Dose, mode: Mode) -> Self {
        Self::StartSelectedProjection { dose, mode }
    }

    /// Create a `Request::StopSelectedProjection`.
    #[must_use]
    pub fn stop_selected_projection(dose: Dose, mode: Mode) -> Self {
        Self::StopSelectedProjection { dose, mode }
    }
}