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,
309 RejectedByInstancesLimit,
311 RejectedBySamplesLimit,
313 RejectedBySamplesPerInstanceLimit,
316}
317
318impl From<cyclonedds_sys::dds_sample_rejected_status_kind> for SampleRejectedReason {
319 fn from(reason: cyclonedds_sys::dds_sample_rejected_status_kind) -> Self {
320 match reason {
321 cyclonedds_sys::dds_sample_rejected_status_kind_DDS_NOT_REJECTED => Self::NotRejected,
322 cyclonedds_sys::dds_sample_rejected_status_kind_DDS_REJECTED_BY_INSTANCES_LIMIT => Self::RejectedByInstancesLimit,
323 cyclonedds_sys::dds_sample_rejected_status_kind_DDS_REJECTED_BY_SAMPLES_LIMIT => Self::RejectedBySamplesLimit,
324 cyclonedds_sys::dds_sample_rejected_status_kind_DDS_REJECTED_BY_SAMPLES_PER_INSTANCE_LIMIT => Self::RejectedBySamplesPerInstanceLimit,
325 value => unreachable!("unsupported value: {value} in conversion to {}", std::any::type_name::<Self>())
326 }
327 }
328}
329
330#[derive(Clone, Copy, Debug, PartialEq, Eq)]
334pub struct SampleRejected {
335 pub total: Counter,
337 pub last_reason: SampleRejectedReason,
339 pub last_instance_handle: crate::entity::InstanceHandle,
341}
342
343#[derive(Clone, Copy, Debug, PartialEq, Eq)]
349pub struct RequestedDeadlineMissed {
350 pub total: Counter,
352 pub last_instance_handle: crate::entity::InstanceHandle,
354}
355
356#[derive(Clone, Copy, Debug, PartialEq, Eq)]
361pub struct RequestedIncompatibleQoS {
362 pub total: Counter,
364 pub last_policy_id: QoSPolicyId,
366}
367
368#[derive(Clone, Copy, Debug, PartialEq, Eq)]
373pub struct SubscriptionMatched {
374 pub total: Counter,
376 pub current: Counter,
378 pub last_publication_handle: crate::entity::InstanceHandle,
380}
381
382#[derive(Clone, Copy, Debug, PartialEq, Eq)]
386pub struct LivelinessChanged {
387 pub alive: Counter,
389 pub not_alive: Counter,
391 pub last_publication_handle: crate::entity::InstanceHandle,
393}
394
395impl From<cyclonedds_sys::dds_inconsistent_topic_status> for InconsistentTopic {
396 fn from(status: cyclonedds_sys::dds_inconsistent_topic_status) -> Self {
397 let total = Counter {
398 count: status.total_count,
399 delta: status.total_count_change,
400 };
401
402 Self { total }
403 }
404}
405
406impl From<cyclonedds_sys::dds_liveliness_lost_status_t> for LivelinessLost {
407 fn from(status: cyclonedds_sys::dds_liveliness_lost_status_t) -> Self {
408 let total = Counter {
409 count: status.total_count,
410 delta: status.total_count_change,
411 };
412 Self { total }
413 }
414}
415
416impl From<cyclonedds_sys::dds_offered_deadline_missed_status_t> for OfferedDeadlineMissed {
417 fn from(status: cyclonedds_sys::dds_offered_deadline_missed_status_t) -> Self {
418 let total = Counter {
419 count: status.total_count,
420 delta: status.total_count_change,
421 };
422 let last_instance_handle = crate::entity::InstanceHandle {
423 inner: status.last_instance_handle,
424 };
425
426 Self {
427 total,
428 last_instance_handle,
429 }
430 }
431}
432
433impl From<cyclonedds_sys::dds_offered_incompatible_qos_status_t> for OfferedIncompatibleQoS {
434 fn from(status: cyclonedds_sys::dds_offered_incompatible_qos_status_t) -> Self {
435 let total = Counter {
436 count: status.total_count,
437 delta: status.total_count_change,
438 };
439 let last_policy_id = status.last_policy_id.into();
440
441 Self {
442 total,
443 last_policy_id,
444 }
445 }
446}
447
448impl From<cyclonedds_sys::dds_publication_matched_status_t> for PublicationMatched {
449 fn from(status: cyclonedds_sys::dds_publication_matched_status_t) -> Self {
450 let total = Counter {
451 count: status.total_count,
452 delta: status.total_count_change,
453 };
454 let current = Counter {
455 count: status.current_count,
456 delta: status.current_count_change,
457 };
458 let last_subscription_handle = crate::entity::InstanceHandle {
459 inner: status.last_subscription_handle,
460 };
461 Self {
462 total,
463 current,
464 last_subscription_handle,
465 }
466 }
467}
468
469impl From<cyclonedds_sys::dds_sample_lost_status_t> for SampleLost {
470 fn from(status: cyclonedds_sys::dds_sample_lost_status_t) -> Self {
471 let total = Counter {
472 count: status.total_count,
473 delta: status.total_count_change,
474 };
475 Self { total }
476 }
477}
478
479impl From<cyclonedds_sys::dds_sample_rejected_status_t> for SampleRejected {
480 fn from(status: cyclonedds_sys::dds_sample_rejected_status_t) -> Self {
481 let total = Counter {
482 count: status.total_count,
483 delta: status.total_count_change,
484 };
485 let last_reason = status.last_reason.into();
486 let last_instance_handle = crate::entity::InstanceHandle {
487 inner: status.last_instance_handle,
488 };
489 Self {
490 total,
491 last_reason,
492 last_instance_handle,
493 }
494 }
495}
496
497impl From<cyclonedds_sys::dds_liveliness_changed_status_t> for LivelinessChanged {
498 fn from(status: cyclonedds_sys::dds_liveliness_changed_status_t) -> Self {
499 let alive = Counter {
500 count: status.alive_count,
501 delta: status.alive_count_change,
502 };
503 let not_alive = Counter {
504 count: status.not_alive_count,
505 delta: status.not_alive_count_change,
506 };
507
508 let last_publication_handle = crate::entity::InstanceHandle {
509 inner: status.last_publication_handle,
510 };
511 Self {
512 alive,
513 not_alive,
514 last_publication_handle,
515 }
516 }
517}
518
519impl From<cyclonedds_sys::dds_requested_deadline_missed_status_t> for RequestedDeadlineMissed {
520 fn from(status: cyclonedds_sys::dds_requested_deadline_missed_status_t) -> Self {
521 let total = Counter {
522 count: status.total_count,
523 delta: status.total_count_change,
524 };
525 let last_instance_handle = crate::entity::InstanceHandle {
526 inner: status.last_instance_handle,
527 };
528 Self {
529 total,
530 last_instance_handle,
531 }
532 }
533}
534
535impl From<cyclonedds_sys::dds_requested_incompatible_qos_status_t> for RequestedIncompatibleQoS {
536 fn from(status: cyclonedds_sys::dds_requested_incompatible_qos_status_t) -> Self {
537 let total = Counter {
538 count: status.total_count,
539 delta: status.total_count_change,
540 };
541 let last_policy_id = status.last_policy_id.into();
542 Self {
543 total,
544 last_policy_id,
545 }
546 }
547}
548
549impl From<cyclonedds_sys::dds_subscription_matched_status_t> for SubscriptionMatched {
550 fn from(status: cyclonedds_sys::dds_subscription_matched_status_t) -> Self {
551 let total = Counter {
552 count: status.total_count,
553 delta: status.total_count_change,
554 };
555 let current = Counter {
556 count: status.current_count,
557 delta: status.current_count_change,
558 };
559 let last_publication_handle = crate::entity::InstanceHandle {
560 inner: status.last_publication_handle,
561 };
562
563 Self {
564 total,
565 current,
566 last_publication_handle,
567 }
568 }
569}
570
571#[cfg(test)]
572mod tests {
573 use super::*;
574
575 #[test]
576 fn test_qos_policy_id_conversion() {
577 let result =
578 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_INVALID_QOS_POLICY_ID as u32);
579 assert_eq!(result, QoSPolicyId::Invalid);
580 let result =
581 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_USERDATA_QOS_POLICY_ID as u32);
582 assert_eq!(result, QoSPolicyId::UserData);
583 let result = QoSPolicyId::from(
584 cyclonedds_sys::dds_qos_policy_id_DDS_DURABILITY_QOS_POLICY_ID as u32,
585 );
586 assert_eq!(result, QoSPolicyId::Durability);
587 let result = QoSPolicyId::from(
588 cyclonedds_sys::dds_qos_policy_id_DDS_PRESENTATION_QOS_POLICY_ID as u32,
589 );
590 assert_eq!(result, QoSPolicyId::Presentation);
591 let result =
592 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_DEADLINE_QOS_POLICY_ID as u32);
593 assert_eq!(result, QoSPolicyId::Deadline);
594 let result = QoSPolicyId::from(
595 cyclonedds_sys::dds_qos_policy_id_DDS_LATENCYBUDGET_QOS_POLICY_ID as u32,
596 );
597 assert_eq!(result, QoSPolicyId::LatencyBudget);
598 let result =
599 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_OWNERSHIP_QOS_POLICY_ID as u32);
600 assert_eq!(result, QoSPolicyId::Ownership);
601 let result = QoSPolicyId::from(
602 cyclonedds_sys::dds_qos_policy_id_DDS_OWNERSHIPSTRENGTH_QOS_POLICY_ID as u32,
603 );
604 assert_eq!(result, QoSPolicyId::OwnershipStrength);
605 let result = QoSPolicyId::from(
606 cyclonedds_sys::dds_qos_policy_id_DDS_LIVELINESS_QOS_POLICY_ID as u32,
607 );
608 assert_eq!(result, QoSPolicyId::Liveliness);
609 let result = QoSPolicyId::from(
610 cyclonedds_sys::dds_qos_policy_id_DDS_TIMEBASEDFILTER_QOS_POLICY_ID as u32,
611 );
612 assert_eq!(result, QoSPolicyId::TimeBasedFilter);
613 let result =
614 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_PARTITION_QOS_POLICY_ID as u32);
615 assert_eq!(result, QoSPolicyId::Partition);
616 let result = QoSPolicyId::from(
617 cyclonedds_sys::dds_qos_policy_id_DDS_RELIABILITY_QOS_POLICY_ID as u32,
618 );
619 assert_eq!(result, QoSPolicyId::Reliability);
620 let result = QoSPolicyId::from(
621 cyclonedds_sys::dds_qos_policy_id_DDS_DESTINATIONORDER_QOS_POLICY_ID as u32,
622 );
623 assert_eq!(result, QoSPolicyId::DestinationOrder);
624 let result =
625 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_HISTORY_QOS_POLICY_ID as u32);
626 assert_eq!(result, QoSPolicyId::History);
627 let result = QoSPolicyId::from(
628 cyclonedds_sys::dds_qos_policy_id_DDS_RESOURCELIMITS_QOS_POLICY_ID as u32,
629 );
630 assert_eq!(result, QoSPolicyId::ResourceLimits);
631 let result = QoSPolicyId::from(
632 cyclonedds_sys::dds_qos_policy_id_DDS_ENTITYFACTORY_QOS_POLICY_ID as u32,
633 );
634 assert_eq!(result, QoSPolicyId::EntityFactory);
635 let result = QoSPolicyId::from(
636 cyclonedds_sys::dds_qos_policy_id_DDS_WRITERDATALIFECYCLE_QOS_POLICY_ID as u32,
637 );
638 assert_eq!(result, QoSPolicyId::WriterDataLifecycle);
639 let result = QoSPolicyId::from(
640 cyclonedds_sys::dds_qos_policy_id_DDS_READERDATALIFECYCLE_QOS_POLICY_ID as u32,
641 );
642 assert_eq!(result, QoSPolicyId::ReaderDataLifecycle);
643 let result =
644 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_TOPICDATA_QOS_POLICY_ID as u32);
645 assert_eq!(result, QoSPolicyId::TopicData);
646 let result =
647 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_GROUPDATA_QOS_POLICY_ID as u32);
648 assert_eq!(result, QoSPolicyId::GroupData);
649 let result = QoSPolicyId::from(
650 cyclonedds_sys::dds_qos_policy_id_DDS_TRANSPORTPRIORITY_QOS_POLICY_ID as u32,
651 );
652 assert_eq!(result, QoSPolicyId::TransportPriority);
653 let result =
654 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_LIFESPAN_QOS_POLICY_ID as u32);
655 assert_eq!(result, QoSPolicyId::Lifespan);
656 let result = QoSPolicyId::from(
657 cyclonedds_sys::dds_qos_policy_id_DDS_DURABILITYSERVICE_QOS_POLICY_ID as u32,
658 );
659 assert_eq!(result, QoSPolicyId::DurabilityService);
660 let result =
661 QoSPolicyId::from(cyclonedds_sys::dds_qos_policy_id_DDS_PROPERTY_QOS_POLICY_ID as u32);
662 assert_eq!(result, QoSPolicyId::Property);
663 let result = QoSPolicyId::from(
664 cyclonedds_sys::dds_qos_policy_id_DDS_TYPE_CONSISTENCY_ENFORCEMENT_QOS_POLICY_ID as u32,
665 );
666 assert_eq!(result, QoSPolicyId::TypeConsistencyEnforcement);
667 let result = QoSPolicyId::from(
668 cyclonedds_sys::dds_qos_policy_id_DDS_DATA_REPRESENTATION_QOS_POLICY_ID as u32,
669 );
670 assert_eq!(result, QoSPolicyId::DataRepresentation);
671 }
672
673 #[test]
674 #[should_panic = "internal error: entered unreachable code: unsupported value"]
675 fn test_qos_policy_id_conversion_out_of_range() {
676 let _ = QoSPolicyId::from(u32::MAX);
677 }
678
679 #[test]
680 fn test_sample_rejected_reason_conversion() {
681 let result = SampleRejectedReason::from(
682 cyclonedds_sys::dds_sample_rejected_status_kind_DDS_NOT_REJECTED,
683 );
684 assert_eq!(result, SampleRejectedReason::NotRejected);
685 let result = SampleRejectedReason::from(
686 cyclonedds_sys::dds_sample_rejected_status_kind_DDS_REJECTED_BY_INSTANCES_LIMIT,
687 );
688 assert_eq!(result, SampleRejectedReason::RejectedByInstancesLimit);
689 let result = SampleRejectedReason::from(
690 cyclonedds_sys::dds_sample_rejected_status_kind_DDS_REJECTED_BY_SAMPLES_LIMIT,
691 );
692 assert_eq!(result, SampleRejectedReason::RejectedBySamplesLimit);
693 let result = SampleRejectedReason::from(cyclonedds_sys::dds_sample_rejected_status_kind_DDS_REJECTED_BY_SAMPLES_PER_INSTANCE_LIMIT);
694 assert_eq!(
695 result,
696 SampleRejectedReason::RejectedBySamplesPerInstanceLimit
697 );
698 }
699
700 #[test]
701 #[should_panic = "internal error: entered unreachable code: unsupported value"]
702 fn test_sample_rejected_reason_conversion_out_of_range() {
703 let _ = SampleRejectedReason::from(cyclonedds_sys::dds_sample_rejected_status_kind::MAX);
704 }
705
706 #[test]
707 fn test_inconsistent_topic_conversion() {
708 let total_count = 10;
709 let total_count_change = 20;
710
711 let status = InconsistentTopic::from(cyclonedds_sys::dds_inconsistent_topic_status {
712 total_count,
713 total_count_change,
714 });
715
716 assert_eq!(
717 (status.total.count, status.total.delta),
718 (total_count, total_count_change)
719 );
720 }
721
722 #[test]
723 fn test_liveliness_lost_conversion() {
724 let total_count = 10;
725 let total_count_change = 20;
726 let status = LivelinessLost::from(cyclonedds_sys::dds_liveliness_lost_status {
727 total_count,
728 total_count_change,
729 });
730
731 assert_eq!(
732 (status.total.count, status.total.delta),
733 (total_count, total_count_change)
734 );
735 }
736
737 #[test]
738 fn test_offered_deadline_missed_conversion() {
739 let total_count = 10;
740 let total_count_change = 20;
741 let last_instance_handle = 30;
742
743 let status =
744 OfferedDeadlineMissed::from(cyclonedds_sys::dds_offered_deadline_missed_status {
745 total_count,
746 total_count_change,
747 last_instance_handle,
748 });
749
750 assert_eq!(
751 (
752 status.total.count,
753 status.total.delta,
754 status.last_instance_handle.inner
755 ),
756 (total_count, total_count_change, last_instance_handle)
757 );
758 }
759
760 #[test]
761 fn test_offered_incompatible_qos_conversion() {
762 let total_count = 10;
763 let total_count_change = 20;
764 let last_policy_id = cyclonedds_sys::dds_qos_policy_id_DDS_DURABILITY_QOS_POLICY_ID as u32;
765
766 let status =
767 OfferedIncompatibleQoS::from(cyclonedds_sys::dds_offered_incompatible_qos_status {
768 total_count,
769 total_count_change,
770 last_policy_id,
771 });
772
773 assert_eq!(
774 (
775 status.total.count,
776 status.total.delta,
777 status.last_policy_id
778 ),
779 (total_count, total_count_change, last_policy_id.into())
780 );
781 }
782
783 #[test]
784 fn test_publication_matched_conversion() {
785 let total_count = 10;
786 let total_count_change = 20;
787 let current_count = 30;
788 let current_count_change = 40;
789 let last_subscription_handle = 50;
790
791 let status = PublicationMatched::from(cyclonedds_sys::dds_publication_matched_status {
792 total_count,
793 total_count_change,
794 current_count,
795 current_count_change,
796 last_subscription_handle,
797 });
798
799 assert_eq!(
800 (
801 status.total.count,
802 status.total.delta,
803 status.current.count,
804 status.current.delta,
805 status.last_subscription_handle.inner
806 ),
807 (
808 total_count,
809 total_count_change,
810 current_count,
811 current_count_change,
812 last_subscription_handle
813 )
814 );
815 }
816
817 #[test]
818 fn test_sample_lost_conversion() {
819 let total_count = 10;
820 let total_count_change = 20;
821
822 let status = SampleLost::from(cyclonedds_sys::dds_sample_lost_status {
823 total_count,
824 total_count_change,
825 });
826
827 assert_eq!(
828 (status.total.count, status.total.delta),
829 (total_count, total_count_change)
830 );
831 }
832
833 #[test]
834 fn test_sample_rejected_conversion() {
835 let total_count = 10;
836 let total_count_change = 20;
837 let last_reason =
838 cyclonedds_sys::dds_sample_rejected_status_kind_DDS_REJECTED_BY_INSTANCES_LIMIT;
839 let last_instance_handle = 40;
840
841 let status = SampleRejected::from(cyclonedds_sys::dds_sample_rejected_status {
842 total_count,
843 total_count_change,
844 last_reason,
845 last_instance_handle,
846 });
847
848 assert_eq!(
849 (
850 status.total.count,
851 status.total.delta,
852 status.last_reason,
853 status.last_instance_handle.inner
854 ),
855 (
856 total_count,
857 total_count_change,
858 last_reason.into(),
859 last_instance_handle
860 )
861 );
862 }
863
864 #[test]
865 fn test_liveliness_changed_conversion() {
866 let alive_count = 10;
867 let alive_count_change = 20;
868 let not_alive_count = 30;
869 let not_alive_count_change = 40;
870 let last_publication_handle = 50;
871
872 let status = LivelinessChanged::from(cyclonedds_sys::dds_liveliness_changed_status {
873 alive_count,
874 alive_count_change,
875 not_alive_count,
876 not_alive_count_change,
877 last_publication_handle,
878 });
879
880 assert_eq!(
881 (
882 status.alive.count,
883 status.alive.delta,
884 status.not_alive.count,
885 status.not_alive.delta,
886 status.last_publication_handle.inner
887 ),
888 (
889 alive_count,
890 alive_count_change,
891 not_alive_count,
892 not_alive_count_change,
893 last_publication_handle
894 )
895 );
896 }
897
898 #[test]
899 fn test_requested_deadline_missed_conversion() {
900 let total_count = 10;
901 let total_count_change = 20;
902 let last_instance_handle = 30;
903
904 let status =
905 RequestedDeadlineMissed::from(cyclonedds_sys::dds_requested_deadline_missed_status {
906 total_count,
907 total_count_change,
908 last_instance_handle,
909 });
910
911 assert_eq!(
912 (
913 status.total.count,
914 status.total.delta,
915 status.last_instance_handle.inner
916 ),
917 (total_count, total_count_change, last_instance_handle)
918 );
919 }
920
921 #[test]
922 fn test_requested_incompatible_qos_conversion() {
923 let total_count = 10;
924 let total_count_change = 20;
925 let last_policy_id = cyclonedds_sys::dds_qos_policy_id_DDS_DURABILITY_QOS_POLICY_ID as u32;
926
927 let status =
928 RequestedIncompatibleQoS::from(cyclonedds_sys::dds_requested_incompatible_qos_status {
929 total_count,
930 total_count_change,
931 last_policy_id,
932 });
933
934 assert_eq!(
935 (
936 status.total.count,
937 status.total.delta,
938 status.last_policy_id
939 ),
940 (total_count, total_count_change, last_policy_id.into())
941 );
942 }
943
944 #[test]
945 fn test_subscription_matched_conversion() {
946 let total_count = 10;
947 let total_count_change = 20;
948 let current_count = 30;
949 let current_count_change = 40;
950 let last_publication_handle = 50;
951
952 let status = SubscriptionMatched::from(cyclonedds_sys::dds_subscription_matched_status {
953 total_count,
954 total_count_change,
955 current_count,
956 current_count_change,
957 last_publication_handle,
958 });
959
960 assert_eq!(
961 (
962 status.total.count,
963 status.total.delta,
964 status.current.count,
965 status.current.delta,
966 status.last_publication_handle.inner
967 ),
968 (
969 total_count,
970 total_count_change,
971 current_count,
972 current_count_change,
973 last_publication_handle
974 )
975 );
976 }
977}