hadoop_hdfs_client/fs/
file_system.rs

1use crate::hdfs::DistributedFileSystem;
2use anyhow::Error;
3use hadoop_common::{conf::Configuration, fs::FileSystem};
4use iref::Iri;
5
6/// Get a FileSystem for this URI's scheme and authority.
7pub fn get(uri: &Iri, conf: &Configuration) -> anyhow::Result<impl FileSystem> {
8    // TODO: fallback to default fs, scheme, authority
9
10    // TODO: CACHE
11
12    create_file_system(uri, conf)
13}
14
15/// Create and initialize a new instance of a FileSystem.
16fn create_file_system(uri: &Iri, conf: &Configuration) -> anyhow::Result<impl FileSystem> {
17    match uri.scheme().as_str() {
18        "hdfs" => Ok(DistributedFileSystem::new(uri, conf)?),
19        _ => Err(Error::msg(format!(
20            "Failed to initialize fileystem {}",
21            uri
22        ))),
23    }
24}