ConnectorUrl

Struct ConnectorUrl 

Source
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: String

Protocol scheme (mqtt, mqtts, kafka, http, https, ws, wss)

§host: String

Host 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

Source

pub fn parse(url: &str) -> DbResult<Self>

Parses a connector URL string

§Supported Formats
  • mqtt://host:port
  • mqtt://user:pass@host:port
  • mqtts://host:port (TLS)
  • kafka://broker1:9092,broker2:9092/topic
  • http://host:port/path
  • https://host:port/path?key=value
  • ws://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()));
Source

pub fn default_port(&self) -> Option<u16>

Returns the default port for this protocol scheme

Source

pub fn effective_port(&self) -> Option<u16>

Returns the effective port (explicit or default)

Source

pub fn is_secure(&self) -> bool

Returns true if this is a secure connection (TLS)

Source

pub fn scheme(&self) -> &str

Returns the URL scheme (protocol)

Source

pub fn path(&self) -> &str

Returns the path component, or “/” if not specified

Source

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

Source§

fn clone(&self) -> ConnectorUrl

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ConnectorUrl

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ConnectorUrl

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ConnectorUrl

Source§

fn eq(&self, other: &ConnectorUrl) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ConnectorUrl

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.