Skip to content

Commit

Permalink
support creating client with configuration (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
zuston authored Jan 5, 2024
1 parent f9b7f82 commit 2c74bcb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
Binary file added ._target
Binary file not shown.
5 changes: 5 additions & 0 deletions rust/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ impl Client {
Self::with_config(&parsed_url, Configuration::new()?)
}

pub fn new_with_config(url: &str, configuration: Configuration) -> Result<Self> {
let parsed_url = Url::parse(url)?;
Self::with_config(&parsed_url, configuration)
}

fn with_config(url: &Url, config: Configuration) -> Result<Self> {
if !url.has_host() {
return Err(HdfsError::InvalidArgument(
Expand Down
6 changes: 6 additions & 0 deletions rust/src/common/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ pub struct Configuration {
map: HashMap<String, String>,
}

impl From<HashMap<String, String>> for Configuration {
fn from(conf_map: HashMap<String, String>) -> Self {
Self { map: conf_map }
}
}

impl Configuration {
pub fn new() -> io::Result<Self> {
let mut map: HashMap<String, String> = HashMap::new();
Expand Down

0 comments on commit 2c74bcb

Please sign in to comment.