Skip to main content

Crate nifi_rust_client

Crate nifi_rust_client 

Source
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_api().get_about_info().await?;
println!("Connected to NiFi {:?}", about.version);

Enable a specific version via Cargo features:

[dependencies]
nifi-rust-client = { version = "0.5", features = ["nifi-2-8-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.5", features = ["dynamic"] }

§Entry points

§Running examples

NIFI_URL=https://localhost:8443 \
NIFI_USERNAME=admin NIFI_PASSWORD=adminpassword123 \
cargo run --example basic_static

All examples accept the same environment variables. See examples/ in the repository for the full set.

§Feature flags

FeaturePurpose

| 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 config::credentials::CredentialProvider;
pub use error::NifiError;

Modules§

builder
Client builder: configure timeouts, TLS, credentials, and retry before connecting.
client
The connected client handle and resource accessor methods.
config
Configuration types: credential providers and retry policy. Client configuration: credential providers and retry policy.
dynamic
error
Error type returned by all client operations.
v2_6_0
v2_7_2
v2_8_0
v2_9_0