ocpi 0.3.5

Unofficial, in progress, OCPI implementation
Documentation
use super::{CancelReservation, ReserveNow, StartSession, StopSession, UnlockConnector};

/// An enum encapsulating all variants of Commands
/// This is not meant to be deserialized or serialized.
/// This is due to how the OCPI spec decided to implement Commands.
/// The tag (discriminant) is a part of the URL, not the body.
#[derive(Debug, Clone)]
pub enum Command {
    CancelReservation(CancelReservation),
    ReserveNow(ReserveNow),
    StartSession(StartSession),
    StopSession(StopSession),
    UnlockConnector(UnlockConnector),
}

impl Command {
    pub fn response_url(&self) -> &url::Url {
        match self {
            Self::CancelReservation(CancelReservation { response_url, .. }) => response_url,
            Self::ReserveNow(ReserveNow { response_url, .. }) => response_url,
            Self::StartSession(StartSession { response_url, .. }) => response_url,
            Self::StopSession(StopSession { response_url, .. }) => response_url,
            Self::UnlockConnector(UnlockConnector { response_url, .. }) => response_url,
        }
    }
}