FirePDU

Struct FirePDU 

Source
pub struct FirePDU {
    pub pdu_header_record: PDUHeaderRecord,
    pub firing_entity_id_record: EntityIDRecord,
    pub target_entity_id_record: EntityIDRecord,
    pub munition_id_record: EntityIDRecord,
    pub event_id_record: EventIDRecord,
    pub fire_mission_index_field: u32,
    pub location_in_world_record: WorldCoordinateRecord,
    pub burst_descriptor_record: BurstDescriptorRecord,
    pub velocity_record: VelocityVectorRecord,
    pub range_field: f32,
}
Expand description

Fire PDU as defined in IEEE 1278.1 standard. Used to communicate a weapon firing during the simulation.

Fields§

§pdu_header_record: PDUHeaderRecord§firing_entity_id_record: EntityIDRecord§target_entity_id_record: EntityIDRecord§munition_id_record: EntityIDRecord§event_id_record: EventIDRecord§fire_mission_index_field: u32§location_in_world_record: WorldCoordinateRecord§burst_descriptor_record: BurstDescriptorRecord§velocity_record: VelocityVectorRecord§range_field: f32

Implementations§

Source§

impl FirePDU

Source

pub fn default() -> Self

Provides a blank FirePDU with all IDs set to 1 (as 0 is not allowed within the DIS protocol).

§Examples

Creating a blank FirePDU:

let fire_pdu = FirePDU::default();

Populating a bank FirePDU’s firing_entity_id_record:

let mut fire_pdu = FirePDU::default();
fire_pdu.firing_entity_id_record = EntityIDRecord::default(2);
Examples found in repository?
examples/broadcast_pdus.rs (line 26)
18fn main() {
19    let src_addr = format!("192.168.1.134:{}", SRC_PORT);
20    println!("binding to {} for sending", src_addr.as_str());
21    let socket = UdpSocket::bind(src_addr).expect("bind should succeed");
22
23    socket.set_broadcast(true).expect("set_broadcast to true should succeed");
24
25    // Send FirePDU
26    let data_to_send = FirePDU::default();
27    println!("broadcasting data: {:?}", data_to_send);
28    let mut buffer = BytesMut::new();
29    PDU::serialise(&data_to_send, &mut buffer);
30    socket
31        .send_to(&buffer, format!("255.255.255.255:{}", SRC_PORT))
32        .expect("couldn't send data");
33
34    // Send EventReportPDU
35    let data_to_send = EventReportPDU::default();
36    println!("broadcasting data: {:?}", data_to_send);
37    let mut buffer = BytesMut::new();
38    PDU::serialise(&data_to_send, &mut buffer);
39    socket
40        .send_to(&buffer, format!("255.255.255.255:{}", SRC_PORT))
41        .expect("couldn't send data");
42
43
44    // Send EntityStatePDU
45    let data_to_send = EntityStatePDU::default();
46    println!("broadcasting data: {:?}", data_to_send);
47    let mut buffer = BytesMut::new();
48    PDU::serialise(&data_to_send, &mut buffer);
49    socket
50        .send_to(&buffer, format!("255.255.255.255:{}", SRC_PORT))
51        .expect("couldn't send data");
52
53    // Send DetonationPDU
54    let data_to_send = DetonationPDU::default();
55    println!("broadcasting data: {:?}", data_to_send);
56    let mut buffer = BytesMut::new();
57    PDU::serialise(&data_to_send, &mut buffer);
58    socket
59        .send_to(&buffer, format!("255.255.255.255:{}", SRC_PORT))
60        .expect("couldn't send data");
61}

Trait Implementations§

Source§

impl Clone for FirePDU

Source§

fn clone(&self) -> FirePDU

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FirePDU

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PDU for FirePDU

Source§

fn serialise(&self, buf: &mut BytesMut)

Fills a BytesMut struct with a FirePDU serialised into binary. This buffer is then ready to be sent via UDP to the simluation network.

Source§

fn deserialise(buffer: BytesMut) -> Result<Self, DISError>
where Self: Sized,

Creates a PDU from a BytesMut struct.
Source§

fn as_any(&self) -> &dyn Any

Source§

fn deserialise_without_header( buffer: BytesMut, pdu_header: PDUHeaderRecord, ) -> Result<Self, DISError>
where Self: Sized,

Creates a PDU from a BytesMut struct.
Source§

impl Copy for FirePDU

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.