rsiot/components_config/uart_general/fieldbus_response.rs
1use std::{fmt::Debug, time::Instant};
2
3use crate::components_config::master_device::RequestResponseBound;
4
5// ANCHOR: FieldbusResponse
6/// Структура отдельного ответа при коммуникации по шине UART
7#[derive(Clone, Debug)]
8pub struct FieldbusResponse {
9 /// Время создания запроса.
10 ///
11 /// Можно контролировать время выполнения запросов
12 pub request_creation_time: Instant,
13
14 /// Вид запроса.
15 ///
16 /// Необходим для правильной расшифровки ответа
17 pub request_kind: u8,
18
19 /// Ответ
20 pub packet: Vec<u8>,
21}
22// ANCHOR: FieldbusResponse
23
24impl FieldbusResponse {
25 // /// Создание ответа
26 // pub fn new(packet: Vec<u8>) -> Self {
27 // Self {
28 // request_creation_time: Instant::now(),
29 // packet,
30 // }
31 // }
32
33 // /// Подготовить ответ для передачи по сети
34 // pub fn to_write_buffer(self) -> Vec<u8> {
35 // self.packet
36 // }
37}
38
39impl RequestResponseBound for FieldbusResponse {}