Skip to content

API Docs

Takanawa exposes the same download core through Rust crates and native platform packages. Published Rust APIs are documented on docs.rs, while platform SDKs are distributed through Maven Central and SwiftPM artifacts.

Rust Crates

Hash Verification

Download configurations can request final file verification with SHA-1, SHA-256, SHA-512, MD5, or CRC32. Rust callers pass a HashConfig variant, the C ABI uses hash_kind with the expected digest bytes, Android uses HashKind/expectedHash, Swift uses HashKind/expectedHash, and Node.js uses hash: { kind, expected } or hash: "kind:<hex>". Existing Android, Swift, and Node.js expectedSha256/sha256 shortcuts continue to select SHA-256.

Digest byte lengths are SHA-1 = 20, SHA-256 = 32, SHA-512 = 64, MD5 = 16, and CRC32 = 4 bytes. CRC32 is represented in standard big-endian hexadecimal order (for example, 352441c2 becomes bytes 35 24 41 c2).

Native Interfaces

The public C header is generated from takanawa-ffi:

sh
mise run header

Android consumers use the Kotlin-first SDK:

kotlin
dependencies {
    implementation("ai.yetanother:takanawa-android:0.3.1")
}

val download = TakanawaDownload.create(config)
download.setProgressCallback { snapshot ->
    println("${snapshot.phase}: ${snapshot.downloadedBytes}/${snapshot.contentLen}")
}
download.start()

Apple consumers use the SwiftPM package and prebuilt Takanawa.xcframework.

swift
let download = try TakanawaDownload.create(config)
try download.setProgressCallback { snapshot in
  print("\(snapshot.phase): \(snapshot.downloadedBytes)/\(snapshot.contentLen)")
}
try download.start()

C ABI consumers can register a nullable TknwProgressCallback with tknw_download_set_progress_callback. Passing NULL clears the callback. C and C++ projects can link the native library through the CMake target Takanawa::takanawa or through the local vcpkg overlay port.

Local Rustdoc

Generate local Rust API documentation with Cargo:

sh
cargo doc --workspace --all-features --no-deps

The generated docs are written under target/doc.

Released under the MIT License.