cyclonedds/state.rs
1//! This holds the state masks that provide information on the state of a
2//! sample, of a view, or of an instance.
3
4bitflags::bitflags! {
5 /// Flags that represent the set of states a sample, view, or instance can
6 /// be in. These are represented privately as a single bit-mask but these
7 /// fields are then re-exported in the [`sample`], [`view`], and
8 /// [`instance`] modules for better organization.
9 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
10 pub struct State: u32 {
11 #[doc(hidden)]
12 const SampleStale = cyclonedds_sys::DDS_READ_SAMPLE_STATE;
13 #[doc(hidden)]
14 const SampleFresh = cyclonedds_sys::DDS_NOT_READ_SAMPLE_STATE;
15 #[doc(hidden)]
16 const SampleAny = cyclonedds_sys::DDS_ANY_SAMPLE_STATE;
17 #[doc(hidden)]
18 const ViewNew = cyclonedds_sys::DDS_NEW_VIEW_STATE;
19 #[doc(hidden)]
20 const ViewOld = cyclonedds_sys::DDS_NOT_NEW_VIEW_STATE;
21 #[doc(hidden)]
22 const ViewAny = cyclonedds_sys::DDS_ANY_VIEW_STATE;
23 #[doc(hidden)]
24 const InstanceAlive = cyclonedds_sys::DDS_ALIVE_INSTANCE_STATE;
25 #[doc(hidden)]
26 const InstanceDisposed = cyclonedds_sys::DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE;
27 #[doc(hidden)]
28 const InstanceUnregistered = cyclonedds_sys::DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE;
29 #[doc(hidden)]
30 const InstanceAny = cyclonedds_sys::DDS_ANY_INSTANCE_STATE;
31 }
32}
33
34pub mod sample {
35 //! This module holds the sample state masks that provide information on the
36 //! state of a sample in the sample info from a read or take call.
37
38 #![allow(non_upper_case_globals)]
39 use super::State;
40
41 /// The sample is stale (has already been read by the reader).
42 pub const Stale: State = State::SampleStale;
43 /// The sample is fresh (in an unread state).
44 pub const Fresh: State = State::SampleFresh;
45 /// The sample is in any read state.
46 pub const Any: State = State::SampleAny;
47}
48
49pub mod view {
50 //! This module holds the set of states of the view of an instance relative
51 //! to the samples.
52
53 #![allow(non_upper_case_globals)]
54 use super::State;
55
56 /// The view is new (the sample is being accessed by the reader for the
57 /// first time when the instance is alive).
58 pub const New: State = State::ViewNew;
59 /// The view is old (the reader has accessed the sample before).
60 pub const Old: State = State::ViewOld;
61 /// The view is in any view state.
62 pub const Any: State = State::ViewAny;
63}
64
65pub mod instance {
66 //! This module holds the set of states of an instance.
67
68 #![allow(non_upper_case_globals)]
69 use super::State;
70
71 /// The instance is alive (is not disposed and has active writers).
72 pub const Alive: State = State::InstanceAlive;
73 /// The instance is disposed (was explicitly disposed by the writer).
74 pub const Disposed: State = State::InstanceDisposed;
75 /// The instance is unregistered (has been declared as not alive by the
76 /// reader as there are no live writers writing that instance).
77 pub const Unregistered: State = State::InstanceUnregistered;
78 /// The instance is in any instance state.
79 pub const Any: State = State::InstanceAny;
80}