---
product: Chilkat
product_version: 11.7.0
language: rust
language_label: Rust
document: language guide
---
> Chilkat 11.7.0 · language=rust · this file: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/rust/guide.md`
> Class pages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/rust/classes/<Class>.md`

# Chilkat for Rust — language guide — v11.7.0

## 1. Which Chilkat binding this is

This is the **Chilkat crate** (`chilkat` on crates.io): structs `chilkat::Http`, `chilkat::Zip`, …, snake_case methods, failures reported as `Result` (`Err` on failure). The prebuilt native library for the target is downloaded at build time (Windows, Linux, Alpine, macOS).

## 2. Install and requirements

```
cargo add chilkat
```

Details: [https://www.chilkatsoft.com/rust.asp](https://www.chilkatsoft.com/rust.asp).

## 3. Unlocking, object creation, lifetime and errors

Generated from the reference documentation for this binding:

**Object Creation**

```rust
// Cargo.toml:
//     [dependencies]
//     chilkat = "11.7"

use chilkat::Global;

// Once per process, before any other Chilkat call:
chilkat::unlock_bundle("Anything for 30-day trial")?;  // shorthand for Global::new().unlock_bundle(..)

let global = Global::new();
// ... the native object is freed when `global` goes out of scope.
```

`pub fn new() -> Global`

Creates the underlying native Chilkat object (`Global` also implements `Default`). Every method takes `&self`, so the object never needs to be declared `mut`. A `Global` is `Send` but not `Sync`: it may be moved to another thread, but a reference to it cannot be shared between threads at the same time.

`impl Drop for Global`

The native object is freed when the `Global` is dropped — when it goes out of scope, or explicitly with `drop(global)`. There is no `Dispose` method to call.

**Errors**

Methods that can fail return `chilkat::Result<T>`, which is `Result<T, chilkat::Error>`: a method whose only outcome is success or failure returns `Result<()>`, a method producing a string or an object returns `Result<String>` or `Result<Global>`. The error carries the object's `LastErrorText` at the time of the failure (`Error::last_error_text`), the class and method names, and implements `std::error::Error`, so `?` works in any function returning `chilkat::Result` or a `Box<dyn Error>`. Properties never fail, and methods that answer a question (`has_...`, `is_...`, ...) return a plain `bool`.

```rust
match global.some_method(...) {
    Ok(value) => println!("{value:?}"),
    Err(e) => eprintln!("{}", e.last_error_text()),
}
```

## 4. Error model

Methods that can fail return a `Result`; on failure the `Err` carries the reason and the object's last-error text is available through its `last_error_text()` accessor. The note under each method on the class page restates this per method. Properties do not fail.

Literals in Rust: true is `true`, false is `false`, null/none is `Err`.

## 5. Strings, bytes and encodings

- Strings are `&str` in and `String` out; a `charset` argument names the encoding of the *bytes* being produced or read.
- Binary data is `&[u8]` in and `Vec<u8>` out; larger or reusable data goes through `chilkat::BinData` (`…_bd` methods) and text through `chilkat::StringBuilder` (`…_sb` methods).
- Methods with `2`/`3` suffixes or `quick_…` prefixes are distinct members, not overloads.

## 6. Object lifetime and threading

Objects implement `Drop`; the native object is released when the Rust value goes out of scope.

A Chilkat object may be used from any thread, but **one object must not be used by two threads at the same time**: create one object per thread or protect it with a lock. Objects are independent — there is no shared global state other than the unlock flag and the few `Global` settings.

## 7. Progress callbacks and async

Progress events are supported through the class's event callbacks (see the "Events and callbacks" section of a class page). Every call is synchronous.

## 8. Common mistakes an AI makes with this binding

1. Using PascalCase member names from other bindings; Rust members are snake_case (`quick_get_str`, `last_error_text`).
2. Ignoring the `Result` (`unwrap()` without printing the last-error text) — match on it and print the diagnostic.
3. Omitting `Global.UnlockBundle` (the program runs in trial mode and stops working after 30 days).
4. Inventing members by analogy with other libraries. If a member is not on the class page, it does not exist — look it up rather than guessing.
5. Using deprecated members that older examples still show. The class page lists each one with its replacement; `deprecated.md` lists them all.
6. Ignoring the failure path. Every Chilkat method reports failure (see each method's note); `LastErrorText` says why, and printing it is the first debugging step.
7. Using one Chilkat object from two threads at the same time. Create one object per thread, or protect it with a lock.

## 9. Instructions block for coding agents

Paste into `CLAUDE.md`, `.cursor/rules`, or Copilot instructions:

```
This project uses Chilkat 11.7.0 from Rust (the chilkat crate; structs chilkat::Http etc., snake_case methods returning Result).
- Reference: https://www.chilkatsoft.com/ai-docs/v/11.7.0/rust/ — read guide.md once, then classes/<Class>.md for each class used.
- Call chilkat::unlock_bundle(...)? once at startup.
- Failures are Err: match on the Result and print the object's last_error_text().
- Never use a member that is not on the class page; never use members listed as deprecated.
```

## 10. Classes

[Class index for Rust](https://www.chilkatsoft.com/ai-docs/v/11.7.0/rust/index.md)
