pub struct ConnectorUrl {
pub scheme: String,
pub host: String,
pub port: Option<u16>,
pub path: Option<String>,
pub username: Option<String>,
pub password: Option<String>,
pub query_params: Vec<(String, String)>,
}Expand description
Parsed connector URL with protocol, host, port, and credentials
Supports multiple protocol schemes:
- MQTT:
mqtt://host:port,mqtts://host:port - Kafka:
kafka://broker1:port,broker2:port/topic - HTTP:
http://host:port/path,https://host:port/path - WebSocket:
ws://host:port/path,wss://host:port/path
Fields§
§scheme: StringProtocol scheme (mqtt, mqtts, kafka, http, https, ws, wss)
host: StringHost or comma-separated list of hosts (for Kafka)
port: Option<u16>Port number (optional, protocol-specific defaults)
path: Option<String>Path component (for HTTP/WebSocket)
username: Option<String>Username for authentication (optional)
password: Option<String>Password for authentication (optional)
query_params: Vec<(String, String)>Query parameters (optional, parsed from URL)
Implementations§
Source§impl ConnectorUrl
impl ConnectorUrl
Sourcepub fn parse(url: &str) -> DbResult<Self>
pub fn parse(url: &str) -> DbResult<Self>
Parses a connector URL string
§Supported Formats
mqtt://host:portmqtt://user:pass@host:portmqtts://host:port(TLS)kafka://broker1:9092,broker2:9092/topichttp://host:port/pathhttps://host:port/path?key=valuews://host:port/mqtt(WebSocket)wss://host:port/mqtt(WebSocket Secure)
§Example
use aimdb_core::connector::ConnectorUrl;
let url = ConnectorUrl::parse("mqtt://user:pass@broker.example.com:1883").unwrap();
assert_eq!(url.scheme, "mqtt");
assert_eq!(url.host, "broker.example.com");
assert_eq!(url.port, Some(1883));
assert_eq!(url.username, Some("user".to_string()));Sourcepub fn default_port(&self) -> Option<u16>
pub fn default_port(&self) -> Option<u16>
Returns the default port for this protocol scheme
Sourcepub fn effective_port(&self) -> Option<u16>
pub fn effective_port(&self) -> Option<u16>
Returns the effective port (explicit or default)
Sourcepub fn resource_id(&self) -> String
pub fn resource_id(&self) -> String
Returns the resource identifier for protocols where the URL specifies a topic/key
This is designed for the simplified connector model where each connector manages a single broker/server connection, and URLs only specify the resource (topic, key, path).
§Examples
mqtt://commands/temperature→"commands/temperature"(topic)mqtt://sensors/temp→"sensors/temp"(topic)kafka://events→"events"(topic)
The format is scheme://resource where resource = host + path combined.
Trait Implementations§
Source§impl Clone for ConnectorUrl
impl Clone for ConnectorUrl
Source§fn clone(&self) -> ConnectorUrl
fn clone(&self) -> ConnectorUrl
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more