datex_core/global/
dxb_block.rs

1use num_enum::TryFromPrimitive;
2
3use crate::datex_values::Endpoint;
4
5
6pub struct DXBBlock {
7	pub header: DXBHeader
8}
9
10#[derive(Debug, Clone, PartialEq)]
11pub struct DXBHeader {
12	pub version: u8,
13
14	pub size: u16,
15
16	pub signed: bool,
17	pub encrypted: bool,
18
19	pub timestamp: u64,
20
21	pub scope_id: u32,
22	pub block_index: u16,
23	pub block_increment: u16,
24	pub block_type: DXBBlockType,
25	pub flags: HeaderFlags,
26
27	pub routing: RoutingInfo
28}
29
30#[derive(Debug, Clone, Copy, PartialEq, TryFromPrimitive)]
31#[repr(u8)]
32pub enum DXBBlockType {
33	REQUEST     = 0, // default datex request
34    RESPONSE    = 1, // response to a request (can be empty)
35
36    DATA        = 2, // data only (limited execution permission)
37    TMP_SCOPE   = 3, // resettable scope
38    
39    LOCAL       = 4, // default datex request, but don't want a response (use for <Function> code blocks, ....), must be sent and executed on same endpoint
40
41    HELLO       = 5, // info message that endpoint is online
42    DEBUGGER    = 6, // get a debugger for a scope
43    SOURCE_MAP  = 7, // send a source map for a scope
44    UPDATE      = 8, // like normal request, but don't propgate updated pointer values back to sender (prevent recursive loop)
45}
46
47#[derive(Debug, Clone, PartialEq)]
48pub struct HeaderFlags {
49	pub allow_execute: bool,
50	pub end_of_scope: bool,
51	pub device_type: u8
52}
53
54#[derive(Debug, Clone, PartialEq)]
55pub struct RoutingInfo {
56	pub ttl: u8,
57	pub priority: u8,
58
59	pub sender: Option<Endpoint>,
60	// pub receivers: Disjunction<Endpoint>
61}