hdrs/lib.rs
1//! hdrs is a HDFS Native Client in Rust based on [hdfs-sys](https://github.com/Xuanwo/hdfs-sys).
2//!
3//! # Examples
4//!
5//! ```no_run
6//! use std::io::{Read, Write};
7//!
8//! use hdrs::Client;
9//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
10//! use hdrs::ClientBuilder;
11//! let fs = ClientBuilder::new("default").connect()?;
12//!
13//! let mut f = fs
14//! .open_file()
15//! .write(true)
16//! .create(true)
17//! .open("/tmp/hello.txt")?;
18//! let n = f.write("Hello, World!".as_bytes())?;
19//!
20//! let mut f = fs.open_file().read(true).open("/tmp/hello.txt")?;
21//! let mut buf = vec![0; 1024];
22//! let n = f.read(&mut buf)?;
23//!
24//! let _ = fs.remove_file("/tmp/hello.txt")?;
25//! # Ok(())
26//! # }
27//! ```
28//!
29//! # Features
30//!
31//! - `async_file`: Enable async operation support
32//! - `vendored`: Ignore lib loading logic, enforce to complie and staticly link libhdfs
33//!
34//! # Compiletime
35//! `hdrs` depends on [hdfs-sys](https://github.com/Xuanwo/hdfs-sys) which links `libjvm` to work.
36//!
37//! Please make sure `JAVA_HOME` is set correctly:
38//!
39//! ```shell
40//! export JAVA_HOME=/path/to/java
41//! export LD_LIBRARY_PATH=${JAVA_HOME}/lib/server:${LD_LIBRARY_PATH}
42//! ```
43//!
44//! - Enable `vendored` feature to compile `libhdfs` and link in static.
45//! - Specify `HDFS_LIB_DIR` or `HADOOP_HOME` to load from specified path instead of compile.
46//! - Specify `HDFS_STATIC=1` to link `libhdfs` in static.
47//! - And finally, we will fallback to compile `libhdfs` and link in static.
48//!
49//! # Runtime
50//!
51//! `hdrs` depends on [hdfs-sys](https://github.com/Xuanwo/hdfs-sys) which uses JNI to call functions provided by jars that provided by hadoop releases.
52//!
53//! Please also make sure `HADOOP_HOME`, `LD_LIBRARY_PATH`, `CLASSPATH` is set correctly during runtime:
54//!
55//! ```shell
56//! export HADOOP_HOME=/path/to/hadoop
57//! export LD_LIBRARY_PATH=${JAVA_HOME}/lib/server:${LD_LIBRARY_PATH}
58//! export CLASSPATH=$(${HADOOP_HOME}/bin/hadoop classpath --glob)
59//! ```
60//!
61//! If `libhdfs` is configued to link dynamiclly, please also add `${HADOOP_HOME}/lib/native` in `LD_LIBRARY_PATH` to make sure linker can find `libhdfs.so`:
62//!
63//! ```shell
64//! export LD_LIBRARY_PATH=${JAVA_HOME}/lib/server:${HADOOP_HOME}/lib/native:${LD_LIBRARY_PATH}
65//! ```
66
67mod client;
68pub use client::{Client, ClientBuilder};
69
70mod file;
71pub use file::File;
72
73#[cfg(feature = "async_file")]
74mod async_file;
75#[cfg(feature = "async_file")]
76pub use async_file::AsyncFile;
77
78mod open_options;
79pub use open_options::OpenOptions;
80
81mod metadata;
82pub use metadata::Metadata;
83
84mod readdir;
85pub use readdir::Readdir;