From 2c74bcbd1c09683c6420595c8d78b60afbf0c0bb Mon Sep 17 00:00:00 2001 From: Junfan Zhang Date: Fri, 5 Jan 2024 21:20:04 +0800 Subject: [PATCH] support creating client with configuration (#52) --- ._target | Bin 0 -> 4096 bytes rust/src/client.rs | 5 +++++ rust/src/common/config.rs | 6 ++++++ 3 files changed, 11 insertions(+) create mode 100644 ._target diff --git a/._target b/._target new file mode 100644 index 0000000000000000000000000000000000000000..72b3f0a123d31594a805bf3ecfa96bf5f007e20c GIT binary patch literal 4096 zcmeH~y$ZrW498PJ)J1f0l5$TV#Zho@bPz#1xRvWQV(ImR_6qt|4nC1DqN%ltF7A@R zk>q~~A-^rq9(AAvu#!rww_+!rR%y_qHwEaQ$y46H0$4W1KWyQ;8!EBt4!BS}|7xMX zMt4*iPh^&9oWy8kAdQ@nNfC(@GCcp&#jzDz-zV1NVJ%okGu}I5Yq1dN+B*MgC fV!||$TAzf*y%D~aNkq5sKfw6h|FzK=?Az@Qa+f*7 literal 0 HcmV?d00001 diff --git a/rust/src/client.rs b/rust/src/client.rs index 25bc7d8..3ed6485 100644 --- a/rust/src/client.rs +++ b/rust/src/client.rs @@ -115,6 +115,11 @@ impl Client { Self::with_config(&parsed_url, Configuration::new()?) } + pub fn new_with_config(url: &str, configuration: Configuration) -> Result { + let parsed_url = Url::parse(url)?; + Self::with_config(&parsed_url, configuration) + } + fn with_config(url: &Url, config: Configuration) -> Result { if !url.has_host() { return Err(HdfsError::InvalidArgument( diff --git a/rust/src/common/config.rs b/rust/src/common/config.rs index 9895bc2..3b18bb3 100644 --- a/rust/src/common/config.rs +++ b/rust/src/common/config.rs @@ -21,6 +21,12 @@ pub struct Configuration { map: HashMap, } +impl From> for Configuration { + fn from(conf_map: HashMap) -> Self { + Self { map: conf_map } + } +} + impl Configuration { pub fn new() -> io::Result { let mut map: HashMap = HashMap::new();