Skip to main content

with_timeout

Function with_timeout 

Source
pub fn with_timeout<F>(
    f: F,
    timeout: Duration,
    ctx: &Context,
    prefix: &str,
) -> Result<CompletionResult>
where F: FnOnce(&Context, &str) -> Result<CompletionResult> + Send + 'static,
Expand description

Wraps a completion function with a timeout

This function ensures that completion operations don’t hang indefinitely by imposing a timeout. If the operation doesn’t complete within the timeout, it returns a partial result with a help message indicating the timeout.

§Arguments

  • f - The completion function to wrap
  • timeout - Maximum duration to wait for completion
  • ctx - The context for the completion
  • prefix - The prefix being completed

§Returns

Returns the completion result if it completes within the timeout, or a partial result with timeout information if it exceeds the timeout.