hdfs_native::client

Struct Client

Source
pub struct Client { /* private fields */ }

Implementations§

Source§

impl Client

Source

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.

Source

pub fn new_with_config( url: &str, config: HashMap<String, String>, ) -> Result<Self>

Source

pub fn default_with_config(config: HashMap<String, String>) -> Result<Self>

Source

pub async fn get_file_info(&self, path: &str) -> Result<FileStatus>

Retrieve the file status for the file at path.

Source

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.

Source

pub fn list_status_iter( &self, path: &str, recursive: bool, ) -> ListStatusIterator

Retrives an iterator of all files in directories located at path.

Source

pub async fn read(&self, path: &str) -> Result<FileReader>

Opens a file reader for the file at path. Path should not include a scheme.

Source

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.

Source

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.

Source

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.

Source

pub async fn rename(&self, src: &str, dst: &str, overwrite: bool) -> Result<()>

Renames src to dst. Returns Ok(()) on success, and Err otherwise.

Source

pub async fn delete(&self, path: &str, recursive: bool) -> Result<bool>

Deletes the file or directory at path. If recursive is false and path is a non-empty directory, this will fail. Returns Ok(true) if it was successfully deleted.

Source

pub async fn set_times(&self, path: &str, mtime: u64, atime: u64) -> Result<()>

Sets the modified and access times for a file. Times should be in milliseconds from the epoch.

Source

pub async fn set_owner( &self, path: &str, owner: Option<&str>, group: Option<&str>, ) -> Result<()>

Optionally sets the owner and group for a file.

Source

pub async fn set_permission(&self, path: &str, permission: u32) -> Result<()>

Sets permissions for a file. Permission should be an octal number reprenting the Unix style permission.

For example, to set permissions to rwxr-xr-x:

client.set_permission("/path", 0o755).await.unwrap();
}
Source

pub async fn set_replication( &self, path: &str, replication: u32, ) -> Result<bool>

Sets the replication for a file.

Source

pub async fn get_content_summary(&self, path: &str) -> Result<ContentSummary>

Gets a content summary for a file or directory rooted at `path

Trait Implementations§

Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Client

Source§

fn default() -> Self

Creates a new HDFS Client based on the fs.defaultFS setting. Panics if the config files fail to load, no defaultFS is defined, or the defaultFS is invalid.

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T