1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! Structures for Remote Procedure Call over DDS, v1.0
//!
//! See the OMG Specification
//
use serde::{Deserialize, Serialize};
use speedy::{Readable, Writable};

use crate::structure::{guid::*, sequence_number::*};

// Spec Section 7.5.1.1.1 Common Types
#[derive(
  Copy,
  Clone,
  Default,
  Debug,
  PartialOrd,
  PartialEq,
  Ord,
  Eq,
  Readable,
  Writable,
  Hash,
  Serialize,
  Deserialize,
)]
// We also derive Copy, although this is a bit large: 32 bytes
// But on 64-bit computers that is only 4 machine words.
pub struct SampleIdentity {
  pub writer_guid: GUID,
  pub sequence_number: SequenceNumber,
}

#[derive(
  Clone,
  Copy,
  Debug,
  PartialOrd,
  PartialEq,
  Ord,
  Eq,
  Readable,
  Writable,
  Hash,
  Serialize,
  Deserialize,
)]
// TODO: Where are the binary serialization values for these specified? Nowhere?
pub enum RemoteExceptionCode {
  Ok,
  Unsupported,
  InvalidArgument,
  OutOfResources,
  UnknownOperation,
  UnknownException,
}

impl Default for RemoteExceptionCode {
  fn default() -> Self {
    Self::UnknownException
  }
}

#[derive(
  Clone, Default, PartialOrd, PartialEq, Ord, Eq, Readable, Writable, Hash, Serialize, Deserialize,
)]
pub struct RequestHeader {
  pub request_id: SampleIdentity,
  pub instance_name: String, // limit to 255 characters
}

#[derive(
  Clone, Default, PartialOrd, PartialEq, Ord, Eq, Readable, Writable, Hash, Serialize, Deserialize,
)]
pub struct ReplyHeader {
  pub related_request_id: SampleIdentity,
  pub remote_ex: RemoteExceptionCode,
}