robotrt-middleware-core 0.1.0-beta.1

RobotRT modular robotics runtime and middleware components.
Documentation
use crate::{QosProfile, RouteRule};

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct TopicQosOverride {
    pub topic: String,
    pub profile: QosProfile,
}

impl TopicQosOverride {
    pub fn new(topic: impl Into<String>, profile: QosProfile) -> Self {
        Self {
            topic: topic.into(),
            profile,
        }
    }
}

#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct MiddlewareRuntimeConfig {
    pub route_rules: Vec<RouteRule>,
    pub topic_qos_overrides: Vec<TopicQosOverride>,
    pub namespace_isolation: bool,
}

impl MiddlewareRuntimeConfig {
    pub fn with_namespace_isolation(mut self, enabled: bool) -> Self {
        self.namespace_isolation = enabled;
        self
    }

    pub fn add_route_rule(mut self, rule: RouteRule) -> Self {
        self.route_rules.push(rule);
        self
    }

    pub fn add_topic_qos_override(mut self, topic: impl Into<String>, profile: QosProfile) -> Self {
        self.topic_qos_overrides
            .push(TopicQosOverride::new(topic, profile));
        self
    }
}