dis-rs 0.13.0

An implementation of the Distributed Interactive Simulation protocol (IEEE-1278.1) in Rust. This main crate contains PDU implementations and facilities to read/write PDUs from Rust data structures to the wire format and vice versa. It supports versions 6 and 7 of the protocol.
Documentation
use crate::common::model::{EntityId, PduBody};
use crate::common::{BodyInfo, Interaction};
use crate::enumerations::PduType;
use crate::resupply_cancel::builder::ResupplyCancelBuilder;
use crate::BodyRaw;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

const RESUPPLY_CANCEL_BASE_BODY_LENGTH: u16 = 12;

/// 5.5.8 Resupply Cancel PDU
///
/// 7.4.5 Resupply Cancel PDU
#[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ResupplyCancel {
    pub requesting_id: EntityId,
    pub servicing_id: EntityId,
}

impl BodyRaw for ResupplyCancel {
    type Builder = ResupplyCancelBuilder;

    fn builder() -> Self::Builder {
        Self::Builder::new()
    }

    fn into_builder(self) -> Self::Builder {
        Self::Builder::new_from_body(self)
    }

    fn into_pdu_body(self) -> PduBody {
        PduBody::ResupplyCancel(self)
    }
}

impl BodyInfo for ResupplyCancel {
    fn body_length(&self) -> u16 {
        RESUPPLY_CANCEL_BASE_BODY_LENGTH
    }

    fn body_type(&self) -> PduType {
        PduType::ResupplyCancel
    }
}

impl Interaction for ResupplyCancel {
    fn originator(&self) -> Option<&EntityId> {
        Some(&self.requesting_id)
    }

    fn receiver(&self) -> Option<&EntityId> {
        Some(&self.servicing_id)
    }
}