Skip to main content
Crate: aic-sdk = "=0.24.0". Core SDK: 0.24.0. Signatures and behavior are based on the released crate source. For installation and a complete audio program, use the Rust guide. Signatures below are declarations. Use the root exports, for example use aic_sdk::{AicError, Model, OtelConfig, ProcessorConfig};. Path and PathBuf refer to std::path types.

Model

A native model handle. Choose a model matching the operation: enhancement for Processor, dedicated voice activity detection (VAD) for Vad and Tyto analysis for the analyzers. One model can supply several independent processing instances. File loading creates a Model<'static>. Buffer loading creates a Model<'a> borrowing its input bytes. The backing bytes must remain valid and immutable for all dependent processors, VADs and analyzers, even if you drop the original model handle. Native reference counting keeps model storage alive; it does not extend the Rust lifetime of borrowed bytes. A file-backed model’s file must not be modified or deleted while the model or dependent objects exist. Model implements Drop, Send and Sync. Dropping the handle releases its native reference. It does not implement Clone; share a reference or use Arc<Model<'static>> when appropriate.

Model::from_file

Loads a model from path. This is blocking setup work. File and model failures return FileSystemError, ModelInvalid or ModelVersionUnsupported, as applicable. Pass a valid path without embedded NUL characters: this release uses CString::new(...).unwrap(), so a NUL-containing path can panic rather than return AicError.

Model::from_buffer

Borrows model bytes without copying the backing buffer. The address must be aligned to 64 bytes; an ordinary Vec<u8> does not guarantee that alignment. Misalignment returns ModelDataUnaligned; invalid contents return model errors. The borrow is carried by the returned model and dependent native objects.

include_model!

Embeds a model file using include_bytes! inside a 64-byte-aligned static allocation and evaluates to a reference to its bytes. The path follows include_bytes! resolution relative to the Rust source file. The file must exist at compile time; this macro does not download it. Its static storage can be used by async processing types. This declaration is a compile-time embedding pattern; replace the path with an existing compatible model file:

Model::id

Returns the model ID borrowed from the native handle. Returns "unknown" if the native string is null or cannot be decoded as UTF-8. The borrowed string cannot outlive this model handle.

Model::optimal_sample_rate

Returns the model’s native sample rate in Hz. This query does not configure or validate an input stream.

Model::optimal_block_size

Returns the preferred sample count per processing call at sample_rate. Use the stream’s actual rate. Initialization validates support for the rate and block combination. Metadata queries return values directly and assert native success; they do not return Result for internal native failures.

Model::download

Requires feature: download-model. Absent when that feature is disabled.
Resolves the model ID against a manifest using the core SDK’s compatible model file version, downloads compatible data and returns its path. The result remains relative when download_dir is relative. Creates missing destination directories. The downloader can reuse a fresh manifest in memory or in the download directory according to server cache lifetime. It revalidates stale entries, retries manifest resolution when needed and reuses a model file only when its SHA-256 matches. Replacement data is checked before installation. Failures return AicError::ModelDownload(String) with the underlying detail. This method blocks and has no async Rust counterpart in this release; provision models before processing.

ProcessorConfig

Construct with a struct literal or optimal. Configuration is copied into the processor, detector or collector at initialization; changing the value later does not reconfigure it. There is no Default implementation.

ProcessorConfig::optimal

Uses the model native rate, its preferred block size at that rate and variable_block_size: false. Override fields before initialization when the input has a different rate.

ProcessorConfig::with_variable_block_size

Consumes the configuration, sets the flag and returns the updated configuration. Does not initialize an object.

OtelConfig

Optional per-instance OpenTelemetry settings for processor and VAD constructors. Without an explicit configuration, native environment defaults apply. These settings control observability separately from mandatory authorization and usage reporting. See telemetry. There is no Default implementation. Configuration is copied at construction; subsequent changes do not affect existing sessions.

OtelConfig::disabled

Returns { enable: false, session_id: None, export_interval_ms: 0 }.

OtelConfig::enabled

Returns { enable: true, session_id: None, export_interval_ms: 0 }.

OtelConfig::with_session_id

Returns enabled telemetry with the converted session ID and interval zero.

get_sdk_version

Returns the loaded native SDK version, which is separate from the Cargo package version. Returns "unknown" for an undecodable native string. Under runtime-linking, this is an SDK call that can trigger automatic library loading.

get_compatible_model_version

Returns the compatible model file format version. This is not the model ID or model release version.

Configuration example

This example needs no model or SDK key:
See the symbol index and features, errors and traits.