Expand description
An idiomatic Rust client for the Apache NiFi 2.x REST API.
This crate provides two usage modes that trade off compile-time determinism against runtime flexibility:
§Static mode (default)
Compile against exactly one NiFi version via a Cargo feature flag. The API surface is fully typed, every endpoint is statically resolved, and the compiler catches any version drift between your code and the server.
use nifi_rust_client::NifiClientBuilder;
let client = NifiClientBuilder::new("https://nifi.example.com:8443")?.build()?;
client.login("admin", "adminpassword123").await?;
let about = client.flow().get_about_info().await?;
println!("Connected to NiFi {:?}", about.version);Enable a specific version via Cargo features:
[dependencies]
nifi-rust-client = { version = "0.12", features = ["nifi-2-9-0"] }§Dynamic mode (dynamic feature)
Compile all supported versions and detect the NiFi server version at
runtime via /flow/about. Use this when your code must talk to multiple
server versions without recompilation.
use nifi_rust_client::NifiClientBuilder;
use nifi_rust_client::dynamic::VersionResolutionStrategy;
let client = NifiClientBuilder::new("https://nifi.example.com:8443")?
.version_strategy(VersionResolutionStrategy::Closest)
.build_dynamic()?;
// login() authenticates AND auto-detects the NiFi version.
client.login("admin", "adminpassword123").await?;Enable via:
[dependencies]
nifi-rust-client = { version = "0.12", features = ["dynamic"] }§Entry points
NifiClientBuilder— construct a client with timeouts, proxies, TLS options, credential providers, and retry policy.NifiClient— the client handle itself; resource accessors like.flow(),.processors(), etc. return borrowed resource structs.NifiError—#[non_exhaustive]error type with typed variants (Unauthorized,Forbidden,NotFound,Conflict,UnsupportedEndpoint, etc.) and helpers likestatus_code()andis_retryable().AuthProviderand its impls (PasswordAuth,EnvPasswordAuth,StaticTokenAuth) in theconfig::authmodule — used withNifiClientBuilder::auth_providerto enable auto-refresh on 401.config::retry::RetryPolicy— exponential-backoff retry on transient errors, configured viaNifiClientBuilder::retry_policy.
§Running examples
NIFI_URL=https://localhost:8443 \
NIFI_USERNAME=admin NIFI_PASSWORD=adminpassword123 \
cargo run --example basic_staticAll examples accept the same environment variables. See examples/ in
the repository for the full set.
§Feature flags
| Feature | Purpose |
|---|
| nifi-2-6-0, nifi-2-7-2, nifi-2-8-0, nifi-2-9-0 | Compile against a specific NiFi version. The semver-latest is the default. |
| dynamic | Compile all versions and enable runtime version detection. Pulls in every version feature. |
At least one version feature (or dynamic) must be enabled — builds with
none fail at both build-script time and compile time.
Re-exports§
pub use builder::NifiClientBuilder;pub use client::NifiClient;pub use compat::FlexibleString;pub use config::auth::AuthProvider;pub use error::NifiError;pub use streaming::BytesStream;pub use v2_9_0::api;pub use v2_9_0::types;
Modules§
- builder
- Client builder: configure timeouts, TLS, credentials, and retry before connecting.
- bulk
- One-shot bulk-control helpers for process groups. One-shot bulk-control helpers for process groups.
- client
- The connected client handle and resource accessor methods.
- compat
- Server-quirk compatibility shims (e.g.
FlexibleStringfor date-time fields that some NiFi versions emit as numbers despite the spec). Server-quirk compatibility shims. - config
- Configuration types: credential providers and retry policy. Client configuration: authentication providers and retry policy.
- dynamic
- error
- Error type returned by all client operations.
- pagination
- Pagination helpers for NiFi REST endpoints that support offset/count paging. Pagination helpers for NiFi REST endpoints.
- streaming
- Streaming byte responses for large binary downloads. Streaming byte responses for endpoints returning unbounded binary payloads (provenance content, flowfile content, NAR/asset downloads).
- v2_9_0
- wait
- Polling helpers for state transitions and async queries. Polling helpers for NiFi state transitions and async queries.
Macros§
- require
- Walk a chain of
Option<T>fields, returning a borrow of the leaf value.
Structs§
- Bytes
- A cheaply cloneable and sliceable chunk of contiguous memory.
Traits§
- Require
Field - Extension trait for
Option<T>that returnsNifiError::MissingFieldinstead of panicking or forcing an.ok_or_elseclosure.