qubit_executor/task/tracked_task_handle.rs
1/*******************************************************************************
2 *
3 * Copyright (c) 2025 - 2026 Haixing Hu.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Licensed under the Apache License, Version 2.0.
8 *
9 ******************************************************************************/
10use super::{
11 cancel_result::CancelResult,
12 task_result_handle::TaskResultHandle,
13 task_status::TaskStatus,
14};
15
16/// Extension interface for handles that expose active task tracking.
17pub trait TrackedTaskHandle<R, E>: TaskResultHandle<R, E> {
18 /// Returns the currently observed task status.
19 ///
20 /// # Returns
21 ///
22 /// The current pending, running, or terminal task status.
23 fn status(&self) -> TaskStatus;
24
25 /// Attempts to cancel the task before it starts.
26 ///
27 /// # Returns
28 ///
29 /// A precise cancellation result describing whether cancellation won.
30 fn cancel(&self) -> CancelResult;
31}