rsiot/components_config/uart_general/
fieldbus_request.rs1use std::{fmt::Debug, time::Instant};
2
3use crate::components_config::master_device::RequestResponseBound;
4
5#[derive(Clone, Debug)]
7pub struct FieldbusRequest {
8 pub request_creation_time: Instant,
12
13 pub packet: Vec<u8>,
15}
16
17impl FieldbusRequest {
18 pub fn new(packet: Vec<u8>) -> Self {
20 Self {
21 request_creation_time: Instant::now(),
22 packet,
23 }
24 }
25
26 pub fn from_read_buffer(read_buf: &[u8]) -> Self {
28 Self {
29 request_creation_time: Instant::now(),
30 packet: read_buf.to_vec(),
31 }
32 }
33
34 pub fn to_write_buffer(self) -> Vec<u8> {
36 self.packet
37 }
38}
39
40impl RequestResponseBound for FieldbusRequest {}