1pub(crate) mod bitflags {
9 bitflags::bitflags! {
10 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
12 pub struct Status: u32 {
13 const InconsistentTopic =
16 1 << cyclonedds_sys::dds_status_id_DDS_INCONSISTENT_TOPIC_STATUS_ID;
17 const OfferedDeadlineMissed =
21 1 << cyclonedds_sys::dds_status_id_DDS_OFFERED_DEADLINE_MISSED_STATUS_ID;
22 const RequestedDeadlineMissed =
26 1 << cyclonedds_sys::dds_status_id_DDS_REQUESTED_DEADLINE_MISSED_STATUS_ID;
27 const OfferedIncompatibleQoS =
30 1 << cyclonedds_sys::dds_status_id_DDS_OFFERED_INCOMPATIBLE_QOS_STATUS_ID;
31 const RequestedIncompatibleQoS =
34 1 << cyclonedds_sys::dds_status_id_DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS_ID;
35 const SampleLost =
37 1 << cyclonedds_sys::dds_status_id_DDS_SAMPLE_LOST_STATUS_ID;
38 const SampleRejected =
40 1 << cyclonedds_sys::dds_status_id_DDS_SAMPLE_REJECTED_STATUS_ID;
41 const DataOnReaders =
44 1 << cyclonedds_sys::dds_status_id_DDS_DATA_ON_READERS_STATUS_ID;
45 const DataAvailable =
47 1 << cyclonedds_sys::dds_status_id_DDS_DATA_AVAILABLE_STATUS_ID;
48 const LivelinessLost =
53 1 << cyclonedds_sys::dds_status_id_DDS_LIVELINESS_LOST_STATUS_ID;
54 const LivelinessChanged =
58 1 << cyclonedds_sys::dds_status_id_DDS_LIVELINESS_CHANGED_STATUS_ID;
59 const PublicationMatched =
62 1 << cyclonedds_sys::dds_status_id_DDS_PUBLICATION_MATCHED_STATUS_ID;
63 const SubscriptionMatched =
66 1 << cyclonedds_sys::dds_status_id_DDS_SUBSCRIPTION_MATCHED_STATUS_ID;
67 }
68 }
69}
70
71#[derive(Debug, Clone, Copy, PartialEq, Eq)]
76pub enum QoSPolicyId {
77 Invalid,
79 UserData,
82 Durability,
85 Presentation,
88 Deadline,
91 LatencyBudget,
94 Ownership,
97 OwnershipStrength,
99 Liveliness,
102 TimeBasedFilter,
105 Partition,
108 Reliability,
111 DestinationOrder,
114 History,
117 ResourceLimits,
120 EntityFactory,
123 WriterDataLifecycle,
126 ReaderDataLifecycle,
129 TopicData,
132 GroupData,
135 TransportPriority,
138 Lifespan,
141 DurabilityService,
144 Property,
146 TypeConsistencyEnforcement,
148 DataRepresentation,
150}
151
152impl From<u32> for QoSPolicyId {
153 fn from(value: u32) -> Self {
154 #[allow(clippy::cast_possible_wrap)]
161 match value as cyclonedds_sys::dds_qos_policy_id_t {
162 cyclonedds_sys::dds_qos_policy_id_DDS_INVALID_QOS_POLICY_ID => Self::Invalid,
163 cyclonedds_sys::dds_qos_policy_id_DDS_USERDATA_QOS_POLICY_ID => Self::UserData,
164 cyclonedds_sys::dds_qos_policy_id_DDS_DURABILITY_QOS_POLICY_ID => Self::Durability,
165 cyclonedds_sys::dds_qos_policy_id_DDS_PRESENTATION_QOS_POLICY_ID => Self::Presentation,
166 cyclonedds_sys::dds_qos_policy_id_DDS_DEADLINE_QOS_POLICY_ID => Self::Deadline,
167 cyclonedds_sys::dds_qos_policy_id_DDS_LATENCYBUDGET_QOS_POLICY_ID => {
168 Self::LatencyBudget
169 }
170 cyclonedds_sys::dds_qos_policy_id_DDS_OWNERSHIP_QOS_POLICY_ID => Self::Ownership,
171 cyclonedds_sys::dds_qos_policy_id_DDS_OWNERSHIPSTRENGTH_QOS_POLICY_ID => {
172 Self::OwnershipStrength
173 }
174 cyclonedds_sys::dds_qos_policy_id_DDS_LIVELINESS_QOS_POLICY_ID => Self::Liveliness,
175 cyclonedds_sys::dds_qos_policy_id_DDS_TIMEBASEDFILTER_QOS_POLICY_ID => {
176 Self::TimeBasedFilter
177 }
178 cyclonedds_sys::dds_qos_policy_id_DDS_PARTITION_QOS_POLICY_ID => Self::Partition,
179 cyclonedds_sys::dds_qos_policy_id_DDS_RELIABILITY_QOS_POLICY_ID => Self::Reliability,
180 cyclonedds_sys::dds_qos_policy_id_DDS_DESTINATIONORDER_QOS_POLICY_ID => {
181 Self::DestinationOrder
182 }
183 cyclonedds_sys::dds_qos_policy_id_DDS_HISTORY_QOS_POLICY_ID => Self::History,
184 cyclonedds_sys::dds_qos_policy_id_DDS_RESOURCELIMITS_QOS_POLICY_ID => {
185 Self::ResourceLimits
186 }
187 cyclonedds_sys::dds_qos_policy_id_DDS_ENTITYFACTORY_QOS_POLICY_ID => {
188 Self::EntityFactory
189 }
190 cyclonedds_sys::dds_qos_policy_id_DDS_WRITERDATALIFECYCLE_QOS_POLICY_ID => {
191 Self::WriterDataLifecycle
192 }
193 cyclonedds_sys::dds_qos_policy_id_DDS_READERDATALIFECYCLE_QOS_POLICY_ID => {
194 Self::ReaderDataLifecycle
195 }
196 cyclonedds_sys::dds_qos_policy_id_DDS_TOPICDATA_QOS_POLICY_ID => Self::TopicData,
197 cyclonedds_sys::dds_qos_policy_id_DDS_GROUPDATA_QOS_POLICY_ID => Self::GroupData,
198 cyclonedds_sys::dds_qos_policy_id_DDS_TRANSPORTPRIORITY_QOS_POLICY_ID => {
199 Self::TransportPriority
200 }
201 cyclonedds_sys::dds_qos_policy_id_DDS_LIFESPAN_QOS_POLICY_ID => Self::Lifespan,
202 cyclonedds_sys::dds_qos_policy_id_DDS_DURABILITYSERVICE_QOS_POLICY_ID => {
203 Self::DurabilityService
204 }
205 cyclonedds_sys::dds_qos_policy_id_DDS_PROPERTY_QOS_POLICY_ID => Self::Property,
206 cyclonedds_sys::dds_qos_policy_id_DDS_TYPE_CONSISTENCY_ENFORCEMENT_QOS_POLICY_ID => {
207 Self::TypeConsistencyEnforcement
208 }
209 cyclonedds_sys::dds_qos_policy_id_DDS_DATA_REPRESENTATION_QOS_POLICY_ID => {
210 Self::DataRepresentation
211 }
212 value => unreachable!(
213 "unsupported value: {value} in conversion to {}",
214 std::any::type_name::<Self>()
215 ),
216 }
217 }
218}
219
220#[derive(Clone, Copy, Debug, PartialEq, Eq)]
225pub struct Counter {
226 pub count: u32,
228 pub delta: i32,
230}
231
232#[derive(Clone, Copy, Debug, PartialEq, Eq)]
237pub struct InconsistentTopic {
238 pub total: Counter,
240}
241
242#[derive(Clone, Copy, Debug, PartialEq, Eq)]
248pub struct LivelinessLost {
249 pub total: Counter,
251}
252
253#[derive(Clone, Copy, Debug, PartialEq, Eq)]
259pub struct OfferedDeadlineMissed {
260 pub total: Counter,
262 pub last_instance_handle: crate::entity::InstanceHandle,
264}
265
266#[derive(Clone, Copy, Debug, PartialEq, Eq)]
271pub struct OfferedIncompatibleQoS {
272 pub total: Counter,
274 pub last_policy_id: QoSPolicyId,
276}
277
278#[derive(Clone, Copy, Debug, PartialEq, Eq)]
283pub struct PublicationMatched {
284 pub total: Counter,
286 pub current: Counter,
288 pub last_subscription_handle: crate::entity::InstanceHandle,
290}
291
292#[derive(Clone, Copy, Debug, PartialEq, Eq)]
296pub struct SampleLost {
297 pub total: Counter,
299}
300
301#[derive(Debug, Copy, Clone, PartialEq, Eq)]
306pub enum SampleRejectedReason {
307 NotRejected,
312 RejectedByInstancesLimit,
314 RejectedBySamplesLimit,
316 RejectedBySamplesPerInstanceLimit,
319}
320
321impl From<cyclonedds_sys::dds_sample_rejected_status_kind> for SampleRejectedReason {
322 fn from(reason: cyclonedds_sys::dds_sample_rejected_status_kind) -> Self {
323 match reason {
324 cyclonedds_sys::dds_sample_rejected_status_kind_DDS_NOT_REJECTED => Self::NotRejected,
325 cyclonedds_sys::dds_sample_rejected_status_kind_DDS_REJECTED_BY_INSTANCES_LIMIT => Self::RejectedByInstancesLimit,
326 cyclonedds_sys::dds_sample_rejected_status_kind_DDS_REJECTED_BY_SAMPLES_LIMIT => Self::RejectedBySamplesLimit,
327 cyclonedds_sys::dds_sample_rejected_status_kind_DDS_REJECTED_BY_SAMPLES_PER_INSTANCE_LIMIT => Self::RejectedBySamplesPerInstanceLimit,
328 value => unreachable!("unsupported value: {value} in conversion to {}", std::any::type_name::<Self>())
329 }
330 }
331}
332
333#[derive(Clone, Copy, Debug, PartialEq, Eq)]
337pub struct SampleRejected {
338 pub total: Counter,
340 pub last_reason: SampleRejectedReason,
342 pub last_instance_handle: crate::entity::InstanceHandle,
344}
345
346#[derive(Clone, Copy, Debug, PartialEq, Eq)]
352pub struct RequestedDeadlineMissed {
353 pub total: Counter,
355 pub last_instance_handle: crate::entity::InstanceHandle,
357}
358
359#[derive(Clone, Copy, Debug, PartialEq, Eq)]
364pub struct RequestedIncompatibleQoS {
365 pub total: Counter,
367 pub last_policy_id: QoSPolicyId,
369}
370
371#[derive(Clone, Copy, Debug, PartialEq, Eq)]
376pub struct SubscriptionMatched {
377 pub total: Counter,
379 pub current: Counter,
381 pub last_publication_handle: crate::entity::InstanceHandle,
383}
384
385#[derive(Clone, Copy, Debug, PartialEq, Eq)]
389pub struct LivelinessChanged {
390 pub alive: Counter,
392 pub not_alive: Counter,
394 pub last_publication_handle: crate::entity::InstanceHandle,
396}
397
398impl From<cyclonedds_sys::dds_inconsistent_topic_status> for InconsistentTopic {
399 fn from(status: cyclonedds_sys::dds_inconsistent_topic_status) -> Self {
400 let total = Counter {
401 count: status.total_count,
402 delta: status.total_count_change,
403 };
404
405 Self { total }
406 }
407}
408
409impl From<cyclonedds_sys::dds_liveliness_lost_status_t> for LivelinessLost {
410 fn from(status: cyclonedds_sys::dds_liveliness_lost_status_t) -> Self {
411 let total = Counter {
412 count: status.total_count,
413 delta: status.total_count_change,
414 };
415 Self { total }
416 }
417}
418
419impl From<cyclonedds_sys::dds_offered_deadline_missed_status_t> for OfferedDeadlineMissed {
420 fn from(status: cyclonedds_sys::dds_offered_deadline_missed_status_t) -> Self {
421 let total = Counter {
422 count: status.total_count,
423 delta: status.total_count_change,
424 };
425 let last_instance_handle = crate::entity::InstanceHandle {
426 inner: status.last_instance_handle,
427 };
428
429 Self {
430 total,
431 last_instance_handle,
432 }
433 }
434}
435
436impl From<cyclonedds_sys::dds_offered_incompatible_qos_status_t> for OfferedIncompatibleQoS {
437 fn from(status: cyclonedds_sys::dds_offered_incompatible_qos_status_t) -> Self {
438 let total = Counter {
439 count: status.total_count,
440 delta: status.total_count_change,
441 };
442 let last_policy_id = status.last_policy_id.into();
443
444 Self {
445 total,
446 last_policy_id,
447 }
448 }
449}
450
451impl From<cyclonedds_sys::dds_publication_matched_status_t> for PublicationMatched {
452 fn from(status: cyclonedds_sys::dds_publication_matched_status_t) -> Self {
453 let total = Counter {
454 count: status.total_count,
455 delta: status.total_count_change,
456 };
457 let current = Counter {
458 count: status.current_count,
459 delta: status.current_count_change,
460 };
461 let last_subscription_handle = crate::entity::InstanceHandle {
462 inner: status.last_subscription_handle,
463 };
464 Self {
465 total,
466 current,
467 last_subscription_handle,
468 }
469 }
470}
471
472impl From<cyclonedds_sys::dds_sample_lost_status_t> for SampleLost {
473 fn from(status: cyclonedds_sys::dds_sample_lost_status_t) -> Self {
474 let total = Counter {
475 count: status.total_count,
476 delta: status.total_count_change,
477 };
478 Self { total }
479 }
480}
481
482impl From<cyclonedds_sys::dds_sample_rejected_status_t> for SampleRejected {
483 fn from(status: cyclonedds_sys::dds_sample_rejected_status_t) -> Self {
484 let total = Counter {
485 count: status.total_count,
486 delta: status.total_count_change,
487 };
488 let last_reason = status.last_reason.into();
489 let last_instance_handle = crate::entity::InstanceHandle {
490 inner: status.last_instance_handle,
491 };
492 Self {
493 total,
494 last_reason,
495 last_instance_handle,
496 }
497 }
498}
499
500impl From<cyclonedds_sys::dds_liveliness_changed_status_t> for LivelinessChanged {
501 fn from(status: cyclonedds_sys::dds_liveliness_changed_status_t) -> Self {
502 let alive = Counter {
503 count: status.alive_count,
504 delta: status.alive_count_change,
505 };
506 let not_alive = Counter {
507 count: status.not_alive_count,
508 delta: status.not_alive_count_change,
509 };
510
511 let last_publication_handle = crate::entity::InstanceHandle {
512 inner: status.last_publication_handle,
513 };
514 Self {
515 alive,
516 not_alive,
517 last_publication_handle,
518 }
519 }
520}
521
522impl From<cyclonedds_sys::dds_requested_deadline_missed_status_t> for RequestedDeadlineMissed {
523 fn from(status: cyclonedds_sys::dds_requested_deadline_missed_status_t) -> Self {
524 let total = Counter {
525 count: status.total_count,
526 delta: status.total_count_change,
527 };
528 let last_instance_handle = crate::entity::InstanceHandle {
529 inner: status.last_instance_handle,
530 };
531 Self {
532 total,
533 last_instance_handle,
534 }
535 }
536}
537
538impl From<cyclonedds_sys::dds_requested_incompatible_qos_status_t> for RequestedIncompatibleQoS {
539 fn from(status: cyclonedds_sys::dds_requested_incompatible_qos_status_t) -> Self {
540 let total = Counter {
541 count: status.total_count,
542 delta: status.total_count_change,
543 };
544 let last_policy_id = status.last_policy_id.into();
545 Self {
546 total,
547 last_policy_id,
548 }
549 }
550}
551
552impl From<cyclonedds_sys::dds_subscription_matched_status_t> for SubscriptionMatched {
553 fn from(status: cyclonedds_sys::dds_subscription_matched_status_t) -> Self {
554 let total = Counter {
555 count: status.total_count,
556 delta: status.total_count_change,
557 };
558 let current = Counter {
559 count: status.current_count,
560 delta: status.current_count_change,
561 };
562 let last_publication_handle = crate::entity::InstanceHandle {
563 inner: status.last_publication_handle,
564 };
565
566 Self {
567 total,
568 current,
569 last_publication_handle,
570 }
571 }
572}
573
574#[cfg(test)]
575mod tests {
576 use super::*;
577
578 #[test]
579 fn test_qos_policy_id_conversion() {
580 let result =
581 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_INVALID_QOS_POLICY_ID as u32);
582 assert_eq!(result, QoSPolicyId::Invalid);
583 let result =
584 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_USERDATA_QOS_POLICY_ID as u32);
585 assert_eq!(result, QoSPolicyId::UserData);
586 let result = QoSPolicyId::from(
587 cyclonedds_sys::dds_qos_policy_id_DDS_DURABILITY_QOS_POLICY_ID as u32,
588 );
589 assert_eq!(result, QoSPolicyId::Durability);
590 let result = QoSPolicyId::from(
591 cyclonedds_sys::dds_qos_policy_id_DDS_PRESENTATION_QOS_POLICY_ID as u32,
592 );
593 assert_eq!(result, QoSPolicyId::Presentation);
594 let result =
595 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_DEADLINE_QOS_POLICY_ID as u32);
596 assert_eq!(result, QoSPolicyId::Deadline);
597 let result = QoSPolicyId::from(
598 cyclonedds_sys::dds_qos_policy_id_DDS_LATENCYBUDGET_QOS_POLICY_ID as u32,
599 );
600 assert_eq!(result, QoSPolicyId::LatencyBudget);
601 let result =
602 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_OWNERSHIP_QOS_POLICY_ID as u32);
603 assert_eq!(result, QoSPolicyId::Ownership);
604 let result = QoSPolicyId::from(
605 cyclonedds_sys::dds_qos_policy_id_DDS_OWNERSHIPSTRENGTH_QOS_POLICY_ID as u32,
606 );
607 assert_eq!(result, QoSPolicyId::OwnershipStrength);
608 let result = QoSPolicyId::from(
609 cyclonedds_sys::dds_qos_policy_id_DDS_LIVELINESS_QOS_POLICY_ID as u32,
610 );
611 assert_eq!(result, QoSPolicyId::Liveliness);
612 let result = QoSPolicyId::from(
613 cyclonedds_sys::dds_qos_policy_id_DDS_TIMEBASEDFILTER_QOS_POLICY_ID as u32,
614 );
615 assert_eq!(result, QoSPolicyId::TimeBasedFilter);
616 let result =
617 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_PARTITION_QOS_POLICY_ID as u32);
618 assert_eq!(result, QoSPolicyId::Partition);
619 let result = QoSPolicyId::from(
620 cyclonedds_sys::dds_qos_policy_id_DDS_RELIABILITY_QOS_POLICY_ID as u32,
621 );
622 assert_eq!(result, QoSPolicyId::Reliability);
623 let result = QoSPolicyId::from(
624 cyclonedds_sys::dds_qos_policy_id_DDS_DESTINATIONORDER_QOS_POLICY_ID as u32,
625 );
626 assert_eq!(result, QoSPolicyId::DestinationOrder);
627 let result =
628 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_HISTORY_QOS_POLICY_ID as u32);
629 assert_eq!(result, QoSPolicyId::History);
630 let result = QoSPolicyId::from(
631 cyclonedds_sys::dds_qos_policy_id_DDS_RESOURCELIMITS_QOS_POLICY_ID as u32,
632 );
633 assert_eq!(result, QoSPolicyId::ResourceLimits);
634 let result = QoSPolicyId::from(
635 cyclonedds_sys::dds_qos_policy_id_DDS_ENTITYFACTORY_QOS_POLICY_ID as u32,
636 );
637 assert_eq!(result, QoSPolicyId::EntityFactory);
638 let result = QoSPolicyId::from(
639 cyclonedds_sys::dds_qos_policy_id_DDS_WRITERDATALIFECYCLE_QOS_POLICY_ID as u32,
640 );
641 assert_eq!(result, QoSPolicyId::WriterDataLifecycle);
642 let result = QoSPolicyId::from(
643 cyclonedds_sys::dds_qos_policy_id_DDS_READERDATALIFECYCLE_QOS_POLICY_ID as u32,
644 );
645 assert_eq!(result, QoSPolicyId::ReaderDataLifecycle);
646 let result =
647 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_TOPICDATA_QOS_POLICY_ID as u32);
648 assert_eq!(result, QoSPolicyId::TopicData);
649 let result =
650 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_GROUPDATA_QOS_POLICY_ID as u32);
651 assert_eq!(result, QoSPolicyId::GroupData);
652 let result = QoSPolicyId::from(
653 cyclonedds_sys::dds_qos_policy_id_DDS_TRANSPORTPRIORITY_QOS_POLICY_ID as u32,
654 );
655 assert_eq!(result, QoSPolicyId::TransportPriority);
656 let result =
657 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_LIFESPAN_QOS_POLICY_ID as u32);
658 assert_eq!(result, QoSPolicyId::Lifespan);
659 let result = QoSPolicyId::from(
660 cyclonedds_sys::dds_qos_policy_id_DDS_DURABILITYSERVICE_QOS_POLICY_ID as u32,
661 );
662 assert_eq!(result, QoSPolicyId::DurabilityService);
663 let result =
664 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_PROPERTY_QOS_POLICY_ID as u32);
665 assert_eq!(result, QoSPolicyId::Property);
666 let result = QoSPolicyId::from(
667 cyclonedds_sys::dds_qos_policy_id_DDS_TYPE_CONSISTENCY_ENFORCEMENT_QOS_POLICY_ID as u32,
668 );
669 assert_eq!(result, QoSPolicyId::TypeConsistencyEnforcement);
670 let result = QoSPolicyId::from(
671 cyclonedds_sys::dds_qos_policy_id_DDS_DATA_REPRESENTATION_QOS_POLICY_ID as u32,
672 );
673 assert_eq!(result, QoSPolicyId::DataRepresentation);
674 }
675
676 #[test]
677 #[should_panic = "internal error: entered unreachable code: unsupported value"]
678 fn test_qos_policy_id_conversion_out_of_range() {
679 let _ = QoSPolicyId::from(u32::MAX);
680 }
681
682 #[test]
683 fn test_sample_rejected_reason_conversion() {
684 let result = SampleRejectedReason::from(
685 cyclonedds_sys::dds_sample_rejected_status_kind_DDS_NOT_REJECTED,
686 );
687 assert_eq!(result, SampleRejectedReason::NotRejected);
688 let result = SampleRejectedReason::from(
689 cyclonedds_sys::dds_sample_rejected_status_kind_DDS_REJECTED_BY_INSTANCES_LIMIT,
690 );
691 assert_eq!(result, SampleRejectedReason::RejectedByInstancesLimit);
692 let result = SampleRejectedReason::from(
693 cyclonedds_sys::dds_sample_rejected_status_kind_DDS_REJECTED_BY_SAMPLES_LIMIT,
694 );
695 assert_eq!(result, SampleRejectedReason::RejectedBySamplesLimit);
696 let result = SampleRejectedReason::from(cyclonedds_sys::dds_sample_rejected_status_kind_DDS_REJECTED_BY_SAMPLES_PER_INSTANCE_LIMIT);
697 assert_eq!(
698 result,
699 SampleRejectedReason::RejectedBySamplesPerInstanceLimit
700 );
701 }
702
703 #[test]
704 #[should_panic = "internal error: entered unreachable code: unsupported value"]
705 fn test_sample_rejected_reason_conversion_out_of_range() {
706 let _ = SampleRejectedReason::from(cyclonedds_sys::dds_sample_rejected_status_kind::MAX);
707 }
708
709 #[test]
710 fn test_inconsistent_topic_conversion() {
711 let total_count = 10;
712 let total_count_change = 20;
713
714 let status = InconsistentTopic::from(cyclonedds_sys::dds_inconsistent_topic_status {
715 total_count,
716 total_count_change,
717 });
718
719 assert_eq!(
720 (status.total.count, status.total.delta),
721 (total_count, total_count_change)
722 );
723 }
724
725 #[test]
726 fn test_liveliness_lost_conversion() {
727 let total_count = 10;
728 let total_count_change = 20;
729 let status = LivelinessLost::from(cyclonedds_sys::dds_liveliness_lost_status {
730 total_count,
731 total_count_change,
732 });
733
734 assert_eq!(
735 (status.total.count, status.total.delta),
736 (total_count, total_count_change)
737 );
738 }
739
740 #[test]
741 fn test_offered_deadline_missed_conversion() {
742 let total_count = 10;
743 let total_count_change = 20;
744 let last_instance_handle = 30;
745
746 let status =
747 OfferedDeadlineMissed::from(cyclonedds_sys::dds_offered_deadline_missed_status {
748 total_count,
749 total_count_change,
750 last_instance_handle,
751 });
752
753 assert_eq!(
754 (
755 status.total.count,
756 status.total.delta,
757 status.last_instance_handle.inner
758 ),
759 (total_count, total_count_change, last_instance_handle)
760 );
761 }
762
763 #[test]
764 fn test_offered_incompatible_qos_conversion() {
765 let total_count = 10;
766 let total_count_change = 20;
767 let last_policy_id = cyclonedds_sys::dds_qos_policy_id_DDS_DURABILITY_QOS_POLICY_ID as u32;
768
769 let status =
770 OfferedIncompatibleQoS::from(cyclonedds_sys::dds_offered_incompatible_qos_status {
771 total_count,
772 total_count_change,
773 last_policy_id,
774 });
775
776 assert_eq!(
777 (
778 status.total.count,
779 status.total.delta,
780 status.last_policy_id
781 ),
782 (total_count, total_count_change, last_policy_id.into())
783 );
784 }
785
786 #[test]
787 fn test_publication_matched_conversion() {
788 let total_count = 10;
789 let total_count_change = 20;
790 let current_count = 30;
791 let current_count_change = 40;
792 let last_subscription_handle = 50;
793
794 let status = PublicationMatched::from(cyclonedds_sys::dds_publication_matched_status {
795 total_count,
796 total_count_change,
797 current_count,
798 current_count_change,
799 last_subscription_handle,
800 });
801
802 assert_eq!(
803 (
804 status.total.count,
805 status.total.delta,
806 status.current.count,
807 status.current.delta,
808 status.last_subscription_handle.inner
809 ),
810 (
811 total_count,
812 total_count_change,
813 current_count,
814 current_count_change,
815 last_subscription_handle
816 )
817 );
818 }
819
820 #[test]
821 fn test_sample_lost_conversion() {
822 let total_count = 10;
823 let total_count_change = 20;
824
825 let status = SampleLost::from(cyclonedds_sys::dds_sample_lost_status {
826 total_count,
827 total_count_change,
828 });
829
830 assert_eq!(
831 (status.total.count, status.total.delta),
832 (total_count, total_count_change)
833 );
834 }
835
836 #[test]
837 fn test_sample_rejected_conversion() {
838 let total_count = 10;
839 let total_count_change = 20;
840 let last_reason =
841 cyclonedds_sys::dds_sample_rejected_status_kind_DDS_REJECTED_BY_INSTANCES_LIMIT;
842 let last_instance_handle = 40;
843
844 let status = SampleRejected::from(cyclonedds_sys::dds_sample_rejected_status {
845 total_count,
846 total_count_change,
847 last_reason,
848 last_instance_handle,
849 });
850
851 assert_eq!(
852 (
853 status.total.count,
854 status.total.delta,
855 status.last_reason,
856 status.last_instance_handle.inner
857 ),
858 (
859 total_count,
860 total_count_change,
861 last_reason.into(),
862 last_instance_handle
863 )
864 );
865 }
866
867 #[test]
868 fn test_liveliness_changed_conversion() {
869 let alive_count = 10;
870 let alive_count_change = 20;
871 let not_alive_count = 30;
872 let not_alive_count_change = 40;
873 let last_publication_handle = 50;
874
875 let status = LivelinessChanged::from(cyclonedds_sys::dds_liveliness_changed_status {
876 alive_count,
877 alive_count_change,
878 not_alive_count,
879 not_alive_count_change,
880 last_publication_handle,
881 });
882
883 assert_eq!(
884 (
885 status.alive.count,
886 status.alive.delta,
887 status.not_alive.count,
888 status.not_alive.delta,
889 status.last_publication_handle.inner
890 ),
891 (
892 alive_count,
893 alive_count_change,
894 not_alive_count,
895 not_alive_count_change,
896 last_publication_handle
897 )
898 );
899 }
900
901 #[test]
902 fn test_requested_deadline_missed_conversion() {
903 let total_count = 10;
904 let total_count_change = 20;
905 let last_instance_handle = 30;
906
907 let status =
908 RequestedDeadlineMissed::from(cyclonedds_sys::dds_requested_deadline_missed_status {
909 total_count,
910 total_count_change,
911 last_instance_handle,
912 });
913
914 assert_eq!(
915 (
916 status.total.count,
917 status.total.delta,
918 status.last_instance_handle.inner
919 ),
920 (total_count, total_count_change, last_instance_handle)
921 );
922 }
923
924 #[test]
925 fn test_requested_incompatible_qos_conversion() {
926 let total_count = 10;
927 let total_count_change = 20;
928 let last_policy_id = cyclonedds_sys::dds_qos_policy_id_DDS_DURABILITY_QOS_POLICY_ID as u32;
929
930 let status =
931 RequestedIncompatibleQoS::from(cyclonedds_sys::dds_requested_incompatible_qos_status {
932 total_count,
933 total_count_change,
934 last_policy_id,
935 });
936
937 assert_eq!(
938 (
939 status.total.count,
940 status.total.delta,
941 status.last_policy_id
942 ),
943 (total_count, total_count_change, last_policy_id.into())
944 );
945 }
946
947 #[test]
948 fn test_subscription_matched_conversion() {
949 let total_count = 10;
950 let total_count_change = 20;
951 let current_count = 30;
952 let current_count_change = 40;
953 let last_publication_handle = 50;
954
955 let status = SubscriptionMatched::from(cyclonedds_sys::dds_subscription_matched_status {
956 total_count,
957 total_count_change,
958 current_count,
959 current_count_change,
960 last_publication_handle,
961 });
962
963 assert_eq!(
964 (
965 status.total.count,
966 status.total.delta,
967 status.current.count,
968 status.current.delta,
969 status.last_publication_handle.inner
970 ),
971 (
972 total_count,
973 total_count_change,
974 current_count,
975 current_count_change,
976 last_publication_handle
977 )
978 );
979 }
980}