client: Require a proper Url to create a client
parent
d90e112c06
commit
5df9ae350c
|
@ -22,7 +22,6 @@ use std::{
|
||||||
ops::Range,
|
ops::Range,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
convert::TryInto,
|
|
||||||
fmt::{self, Debug},
|
fmt::{self, Debug},
|
||||||
future::Future,
|
future::Future,
|
||||||
io::Read,
|
io::Read,
|
||||||
|
@ -477,7 +476,7 @@ impl Client {
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `homeserver_url` - The homeserver that the client should connect to.
|
/// * `homeserver_url` - The homeserver that the client should connect to.
|
||||||
pub fn new(homeserver_url: impl TryInto<Url>) -> Result<Self> {
|
pub fn new(homeserver_url: Url) -> Result<Self> {
|
||||||
let config = ClientConfig::new();
|
let config = ClientConfig::new();
|
||||||
Client::new_with_config(homeserver_url, config)
|
Client::new_with_config(homeserver_url, config)
|
||||||
}
|
}
|
||||||
|
@ -489,15 +488,8 @@ impl Client {
|
||||||
/// * `homeserver_url` - The homeserver that the client should connect to.
|
/// * `homeserver_url` - The homeserver that the client should connect to.
|
||||||
///
|
///
|
||||||
/// * `config` - Configuration for the client.
|
/// * `config` - Configuration for the client.
|
||||||
pub fn new_with_config(
|
pub fn new_with_config(homeserver_url: Url, config: ClientConfig) -> Result<Self> {
|
||||||
homeserver_url: impl TryInto<Url>,
|
let homeserver = Arc::new(homeserver_url);
|
||||||
config: ClientConfig,
|
|
||||||
) -> Result<Self> {
|
|
||||||
let homeserver = if let Ok(u) = homeserver_url.try_into() {
|
|
||||||
Arc::new(u)
|
|
||||||
} else {
|
|
||||||
panic!("Error parsing homeserver url")
|
|
||||||
};
|
|
||||||
|
|
||||||
let client = if let Some(client) = config.client {
|
let client = if let Some(client) = config.client {
|
||||||
client
|
client
|
||||||
|
|
Loading…
Reference in New Issue