cyclonedds_sys/
lib.rs

1/*
2    Copyright 2020 Sojan James
3
4    Licensed under the Apache License, Version 2.0 (the "License");
5    you may not use this file except in compliance with the License.
6    You may obtain a copy of the License at
7
8        http://www.apache.org/licenses/LICENSE-2.0
9
10    Unless required by applicable law or agreed to in writing, software
11    distributed under the License is distributed on an "AS IS" BASIS,
12    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    See the License for the specific language governing permissions and
14    limitations under the License.
15*/
16
17#![allow(non_upper_case_globals)]
18#![allow(non_camel_case_types)]
19#![allow(non_snake_case)]
20
21use bitmask::bitmask;
22
23include!("generated.rs");
24
25pub mod dds_error;
26pub use dds_error::DDSError;
27
28//// some macros we need to use in Rust
29pub const DDS_FREE_KEY_BIT: u32 =  0x01;
30pub const DDS_FREE_CONTENTS_BIT:u32 =  0x02;
31pub const DDS_FREE_ALL_BIT:u32 =  0x04;
32
33
34#[derive(Clone,PartialEq)]
35pub struct DdsEntity(dds_entity_t);
36
37impl DdsEntity {
38    pub unsafe fn new(entity: dds_entity_t) -> Self {
39        DdsEntity(entity)
40    }
41    pub unsafe fn entity(&self) -> dds_entity_t {
42        self.0
43    }
44}
45
46pub mod builtin_entity {
47    use crate::DdsEntity;
48    pub const BUILTIN_TOPIC_DCPSPARTICIPANT_ENTITY : DdsEntity = DdsEntity(crate::BUILTIN_TOPIC_DCPSPARTICIPANT);
49    pub const BUILTIN_TOPIC_DCPSTOPIC_ENTITY : DdsEntity = DdsEntity(crate::BUILTIN_TOPIC_DCPSTOPIC);
50    pub const BUILTIN_TOPIC_DCPSPUBLICATION_ENTITY : DdsEntity = DdsEntity(crate::BUILTIN_TOPIC_DCPSPUBLICATION);
51    pub const BUILTIN_TOPIC_DCPSSUBSCRIPTION : DdsEntity = DdsEntity(crate::BUILTIN_TOPIC_DCPSSUBSCRIPTION);
52}
53
54pub type DdsDomainId = dds_domainid_t;
55pub type DdsTopicDescriptor = dds_topic_descriptor_t;
56
57bitmask! {
58    pub mask StateMask : u32 where flags State {
59        DdsReadSampleState = 0x1,
60        DdsNotReadSampleState = 0x2,
61        DdsAnySampleState = 0x1 | 0x2,
62        DdsNewViewState = 0x4,
63        DdsNotNewViewState = 0x8,
64        DdsAnyViewState = 0x4 | 0x8,
65        DdsAliveInstanceState = 16,
66        DdsNotAliveDisposedInstanceState = 32,
67        DdsNotAliveNoWritersInstanceState = 64,
68        DdsAnyInstanceState = 16 | 32 | 64,
69        DdsAnyState =  1 | 2  | 4 | 8 | 16 | 32 | 64,
70    }
71}