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;
use crate::common::model::SupplyQuantity;
use crate::resupply_offer::model::ResupplyOffer;

pub struct ResupplyOfferBuilder(ResupplyOffer);

impl Default for ResupplyOfferBuilder {
    fn default() -> Self {
        Self::new()
    }
}

impl ResupplyOfferBuilder {
    #[must_use]
    pub fn new() -> Self {
        ResupplyOfferBuilder(ResupplyOffer::default())
    }

    #[must_use]
    pub fn new_from_body(body: ResupplyOffer) -> Self {
        ResupplyOfferBuilder(body)
    }

    #[must_use]
    pub fn build(self) -> ResupplyOffer {
        self.0
    }

    #[must_use]
    pub fn with_requesting_id(mut self, requesting_id: EntityId) -> Self {
        self.0.requesting_id = requesting_id;
        self
    }

    #[must_use]
    pub fn with_servicing_id(mut self, servicing_id: EntityId) -> Self {
        self.0.servicing_id = servicing_id;
        self
    }

    #[must_use]
    pub fn with_supply(mut self, supplies: SupplyQuantity) -> Self {
        self.0.supplies.push(supplies);
        self
    }

    #[must_use]
    pub fn with_supplies(mut self, supplies: Vec<SupplyQuantity>) -> Self {
        self.0.supplies = supplies;
        self
    }
}