pub struct ProcessorAsync { /* private fields */ }async only.Expand description
A wrapper around Processor for use in async contexts.
§Threading
Processing runs on a background thread pool shared across all
ProcessorAsync instances. The pool defaults to one thread per logical
CPU. Override with the AIC_NUM_THREADS environment variable, which is
read once on first use.
§Example
use aic_sdk::{Model, ProcessorAsync, ProcessorConfig};
#[tokio::main]
async fn main() -> Result<(), aic_sdk::AicError> {
let license_key = std::env::var("AIC_SDK_LICENSE").unwrap();
let model = Model::from_file("/path/to/model.aicmodel")?;
let config = ProcessorConfig::optimal(&model);
let processor = ProcessorAsync::new(&model, &license_key)?.with_config(&config).await?;
let mut audio = vec![0.0f32; config.block_size];
let audio = processor.process(audio).await?;
Ok(())
}Implementations§
Source§impl ProcessorAsync
impl ProcessorAsync
Sourcepub fn new(model: &Model<'static>, license_key: &str) -> Result<Self, AicError>
pub fn new(model: &Model<'static>, license_key: &str) -> Result<Self, AicError>
Creates a new async audio enhancement processor instance.
See Processor::new for details.
Sourcepub fn with_otel_config(
model: &Model<'static>,
license_key: &str,
otel_config: &OtelConfig,
) -> Result<Self, AicError>
pub fn with_otel_config( model: &Model<'static>, license_key: &str, otel_config: &OtelConfig, ) -> Result<Self, AicError>
Creates a new async audio enhancement processor instance with explicit OpenTelemetry configuration.
See Processor::with_otel_config for details.
Sourcepub async fn with_config(
self,
config: &ProcessorConfig,
) -> Result<Self, AicError>
pub async fn with_config( self, config: &ProcessorConfig, ) -> Result<Self, AicError>
Initializes the async processor with the given configuration.
This is a convenience method that calls ProcessorAsync::initialize
internally and returns self.
Sourcepub async fn initialize(&self, config: &ProcessorConfig) -> Result<(), AicError>
pub async fn initialize(&self, config: &ProcessorConfig) -> Result<(), AicError>
Initializes the processor with the given configuration.
See Processor::initialize for details.
§Warning
This allocates memory internally. Do not call from latency-sensitive paths.
Sourcepub async fn process(&self, audio: Vec<f32>) -> Result<Vec<f32>, AicError>
pub async fn process(&self, audio: Vec<f32>) -> Result<Vec<f32>, AicError>
Processes mono audio.
This method takes ownership of audio, moves it to a background processing
thread, and returns the processed audio block.
See Processor::process for details.
Sourcepub async fn terminate_session(&self) -> Result<(), AicError>
pub async fn terminate_session(&self) -> Result<(), AicError>
Terminates the telemetry session associated with this processor.
See Processor::terminate_session for details.
§Warning
This may block until the session is terminated, so it runs on the background thread pool rather than the calling task.
Sourcepub async fn context(&self) -> ProcessorContext
pub async fn context(&self) -> ProcessorContext
Returns a ProcessorContext for real-time parameter control.
See Processor::context for details.
Auto Trait Implementations§
impl !RefUnwindSafe for ProcessorAsync
impl !UnwindSafe for ProcessorAsync
impl Freeze for ProcessorAsync
impl Send for ProcessorAsync
impl Sync for ProcessorAsync
impl Unpin for ProcessorAsync
impl UnsafeUnpin for ProcessorAsync
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more