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: f32Implementations§
Source§impl FirePDU
impl FirePDU
Sourcepub fn default() -> Self
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 PDU for FirePDU
impl PDU for FirePDU
Source§fn serialise(&self, buf: &mut BytesMut)
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,
fn deserialise(buffer: BytesMut) -> Result<Self, DISError>where
Self: Sized,
Creates a PDU from a BytesMut struct.
fn as_any(&self) -> &dyn Any
Source§fn deserialise_without_header(
buffer: BytesMut,
pdu_header: PDUHeaderRecord,
) -> Result<Self, DISError>where
Self: Sized,
fn deserialise_without_header(
buffer: BytesMut,
pdu_header: PDUHeaderRecord,
) -> Result<Self, DISError>where
Self: Sized,
Creates a PDU from a BytesMut struct.
impl Copy for FirePDU
Auto Trait Implementations§
impl Freeze for FirePDU
impl RefUnwindSafe for FirePDU
impl Send for FirePDU
impl Sync for FirePDU
impl Unpin for FirePDU
impl UnwindSafe for FirePDU
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more