Struct hdfs_native::client::Client
source · pub struct Client { /* private fields */ }
Implementations§
source§impl Client
impl Client
sourcepub fn new(url: &str) -> Result<Self>
pub fn new(url: &str) -> Result<Self>
Creates a new HDFS Client. The URL must include the protocol and host, and optionally a port. If a port is included, the host is treated as a single NameNode. If no port is included, the host is treated as a name service that will be resolved using the HDFS config.
pub fn new_with_config( url: &str, config: HashMap<String, String> ) -> Result<Self>
sourcepub async fn get_file_info(&self, path: &str) -> Result<FileStatus>
pub async fn get_file_info(&self, path: &str) -> Result<FileStatus>
Retrieve the file status for the file at path
.
sourcepub async fn list_status(
&self,
path: &str,
recursive: bool
) -> Result<Vec<FileStatus>>
pub async fn list_status( &self, path: &str, recursive: bool ) -> Result<Vec<FileStatus>>
Retrives a list of all files in directories located at path
. Wrapper around list_status_iter
that
returns Err if any part of the stream fails, or Ok if all file statuses were found successfully.
sourcepub fn list_status_iter(
&self,
path: &str,
recursive: bool
) -> ListStatusIterator
pub fn list_status_iter( &self, path: &str, recursive: bool ) -> ListStatusIterator
Retrives an iterator of all files in directories located at path
.
sourcepub async fn read(&self, path: &str) -> Result<FileReader>
pub async fn read(&self, path: &str) -> Result<FileReader>
Opens a file reader for the file at path
. Path should not include a scheme.
sourcepub async fn create(
&self,
src: &str,
write_options: impl AsRef<WriteOptions>
) -> Result<FileWriter>
pub async fn create( &self, src: &str, write_options: impl AsRef<WriteOptions> ) -> Result<FileWriter>
Opens a new file for writing. See WriteOptions for options and behavior for different scenarios.
sourcepub async fn append(&self, src: &str) -> Result<FileWriter>
pub async fn append(&self, src: &str) -> Result<FileWriter>
Opens an existing file for appending. An Err will be returned if the file does not exist. If the file is replicated, the current block will be appended to until it is full. If the file is erasure coded, a new block will be created.
sourcepub async fn mkdirs(
&self,
path: &str,
permission: u32,
create_parent: bool
) -> Result<()>
pub async fn mkdirs( &self, path: &str, permission: u32, create_parent: bool ) -> Result<()>
Create a new directory at path
with the given permission
.
permission
is the raw octal value representing the Unix style permission. For example, to
set 755 (rwxr-x-rx
) permissions, use 0o755.
If create_parent
is true, any missing parent directories will be created as well,
otherwise an error will be returned if the parent directory doesn’t already exist.