Chilkat for Rust — the chilkat crate
Chilkat for Rust is the chilkat crate on
crates.io: one struct per Chilkat class, Result-returning methods, snake_case names, and
progress events through a trait. HTTP and REST, email (SMTP, POP3, IMAP, MIME), FTP, SFTP, SSH, zip and compression,
encryption, digital signatures, certificates, XML, JSON, sockets and more — the same functionality as every
other Chilkat product.
Jump to: Add to your project · Quick start · Supported targets · Offline builds · How the API maps to Rust · Licensing
Documentation & Samples
- 📖 Chilkat Rust Reference Documentation — every class, method and property with its Rust signature
- 💻 Chilkat Rust Sample Code — ready-to-run examples
- 📦 chilkat on crates.io · API docs on docs.rs · chilkat-sys (the raw FFI crate the safe API is built on)
- 📝 Release Notes on the Chilkat blog
Add to your project
cargo add chilkat
or add the dependency to Cargo.toml by hand:
[dependencies] chilkat = "11.6"
Then cargo build. On the first build the chilkat-sys build script downloads
chilkat-rust-<target>.tar.gz for your target triple from
https://chilkatdownload.com/<version>/, checks its SHA-256 against the table
compiled into the crate, unpacks it into your user cache directory (~/.cache/chilkat
on Linux, ~/Library/Caches/chilkat on macOS,
%LOCALAPPDATA%\chilkat on Windows), and links it statically. Later builds — in
this project or any other — reuse the cached, verified copy, so the download happens once per Chilkat
version per target.
Quick start
use chilkat::{Http, JsonObject};
fn main() -> chilkat::Result<()> {
// Any string unlocks the fully functional 30-day trial. Call once per process.
chilkat::unlock_bundle("Anything for 30-day trial")?;
let http = Http::new();
let body = http.quick_get_str("https://api.github.com/repos/rust-lang/rust")?;
let json = JsonObject::new();
json.load(&body)?;
println!("{} stars", json.int_of("stargazers_count"));
Ok(())
}
Every method that can fail returns chilkat::Result<T>, so ? works as usual. The
error carries the object's LastErrorText from the moment of the failure
(e.last_error_text()), the class and method names, and implements std::error::Error.
Supported targets
A prebuilt Chilkat library is published for each of these Rust target triples with every Chilkat release. The archive is what the build script downloads; the name is chilkat-rust-<triple>.tar.gz.
| Platform | Target triple | Notes |
|---|---|---|
| Windows (MSVC) | x86_64-pc-windows-msvc | Each archive holds chilkat.lib (dynamic CRT, /MD, the default) and chilkat_mt.lib (static CRT, /MT). Building with -C target-feature=+crt-static links the /MT flavour automatically. |
| i686-pc-windows-msvc | ||
| aarch64-pc-windows-msvc | ||
| Linux (glibc) | x86_64-unknown-linux-gnu | Debian/Ubuntu, RHEL/Fedora, SUSE, Arch, Raspberry Pi OS, … — any glibc-based distribution. |
| aarch64-unknown-linux-gnu | ||
| armv7-unknown-linux-gnueabihf | ||
| i686-unknown-linux-gnu | ||
| Alpine Linux (musl) | x86_64-unknown-linux-musl | Alpine and other musl-based systems, including rust:*-alpine Docker images and fully static binaries. |
| aarch64-unknown-linux-musl | ||
| armv7-unknown-linux-musleabihf | ||
| i686-unknown-linux-musl | ||
| macOS | aarch64-apple-darwin | Apple silicon and Intel; a universal binary needs one build per target. |
| x86_64-apple-darwin |
Cross-compiling works the same way: the build script downloads the archive for the
--target you pass to cargo, not for the host. A target not in this table fails the build with a
message naming the supported targets; if you need another one,
contact Chilkat support.
Offline builds, vendoring, and your own Chilkat library
Build machines without internet access, or that must not download during a build, point the build script at a library directory instead:
# Linux / macOS: the directory containing libchilkat.a CHILKAT_LIB_DIR=/opt/chilkat/lib cargo build --release # Windows (MSVC): the directory containing chilkat.lib (and chilkat_mt.lib) set CHILKAT_LIB_DIR=C:\chilkat\lib cargo build --release
To populate that directory, download the archive for your target once from a connected machine and unpack it — the URL is
https://chilkatdownload.com/<version>/chilkat-rust-<target triple>.tar.gz
# for example, for chilkat = "11.6.1" on 64-bit Linux:
https://chilkatdownload.com/11.6.1/chilkat-rust-x86_64-unknown-linux-gnu.tar.gz
where <version> is the exact version of the chilkat crate you depend on
(shown on crates.io and in Cargo.lock). Each archive contains
the static library, license.pdf, a software bill of materials, and a
VERSION file. The SHA-256 of every published archive is listed in the
checksums.txt file inside the chilkat-sys crate of the same version.
All build-script settings:
| Environment variable | Effect |
|---|---|
| CHILKAT_LIB_DIR | Directory containing the Chilkat static library. When set, nothing is downloaded. |
| CHILKAT_LIB_NAME | Library name without prefix/extension when it is not chilkat (for example ChilkatRelDll_x64 from a Chilkat C++ distribution). Used with CHILKAT_LIB_DIR. |
| CHILKAT_CACHE_DIR | Where downloaded archives are unpacked and reused, instead of the user cache directory. Useful on CI to keep the cache between jobs. |
| CHILKAT_DOWNLOAD_BASE | Base URL to download from, instead of https://chilkatdownload.com — for an internal mirror that serves the same <version>/chilkat-rust-<triple>.tar.gz paths. The SHA-256 check still applies. |
The build script never downloads on docs.rs, and a checksum mismatch fails the build rather than linking an unverified library.
How the Chilkat API maps to Rust
| Chilkat | Rust |
|---|---|
| Class Http, CkDateTime | chilkat::Http, chilkat::DateTime — created with Http::new(), freed when dropped. Every method takes &self, so objects are never declared mut. Objects are Send but not Sync. |
| Method QuickGetStr, property AllowGzip | quick_get_str(); allow_gzip() / set_allow_gzip(bool) |
| Method returning success/failure (bool) | Result<()> |
| Method returning a string or an object (null on failure) | Result<String>, Result<Cert>, … |
| Method answering a question (HasMember, IsValid, TagEquals, …) | plain bool |
| Byte arrays | &[u8] in, Vec<u8> out (via BinData) |
| Events (AbortCheck, PercentDone, ProgressInfo) | Implement the chilkat::EventHandler trait and call set_event_handler, or use the on_percent_done(|pct| ..) closure methods. |
| *Async methods, Task, TaskChain | Not included. Chilkat calls are synchronous; use Rust threads or spawn_blocking in an async runtime. Objects can be moved to another thread. |
The reference documentation shows the exact Rust signature of every member.
Licensing
This is the full-version Chilkat product. Chilkat libraries are
fully functional for a 30-day evaluation; passing any
non-empty string to chilkat::unlock_bundle starts the trial, and a purchased unlock code removes the time
limit. The license terms are in the LICENSE file of the crate (and
license.pdf in every native archive). For questions, see the
reference documentation or
contact Chilkat support.