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 endpoint URL with protocol, host, port, and credentials
This is the URL a connector is constructed with (broker/gateway/server
endpoint) — record links use the far simpler LinkAddress instead.
The parser is scheme-agnostic: any scheme://… URL parses. Connectors in
this workspace use e.g.:
- MQTT:
mqtt://host:port,mqtts://host:port - KNX:
knx://gateway:3671 - WebSocket:
ws://host:port/path,wss://host:port/path
Fields§
§scheme: StringProtocol scheme (e.g. mqtt, mqtts, knx, ws, wss, uds, serial)
host: StringHost, or a comma-separated host list (preserved verbatim)
port: Option<u16>Port number (optional, protocol-specific defaults)
path: Option<String>Path component (optional)
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)knx://gateway:3671ws://host:port/path?key=value(WebSocket)wss://host:port/path(WebSocket Secure)
Any other scheme://… parses the same way; comma-separated host
lists are preserved verbatim in host.
§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)
Trait Implementations§
Source§impl Clone for ConnectorUrl
impl Clone for ConnectorUrl
Source§fn clone(&self) -> ConnectorUrl
fn clone(&self) -> ConnectorUrl
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more