Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose server_uri with AsyncClient #203

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/async_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,14 @@ impl AsyncClient {
pub fn client_id(&self) -> String {
self.inner.client_id.clone().into_string().unwrap()
}

/// Returns server URI used for connection
///
/// Server URI is returned as a rust String as set in a
/// CreateOptionsBuilder for symmetry
pub fn server_uri(&self) -> String {
self.inner.server_uri.clone().into_string().unwrap()
}
}

// The client is safe to send or share between threads.
Expand Down Expand Up @@ -1370,4 +1378,18 @@ mod tests {
let retrieved = client.unwrap().client_id();
assert_eq!(retrieved, c_id.to_string());
}

#[test]
fn test_get_server_uri() {
let server_uri = "tcp://localhost:1883";
let client = CreateOptionsBuilder::new()
.server_uri(server_uri)
.create_client();
assert!(
client.is_ok(),
"Error in creating async client with server_uri"
);
let retrieved = client.unwrap().server_uri();
assert_eq!(retrieved, server_uri.to_string());
}
}