pub struct Task {
pub task_id: String,
pub status: TaskStatus,
pub status_message: Option<String>,
pub created_at: String,
pub last_updated_at: String,
pub ttl: Option<u64>,
pub poll_interval: Option<u64>,
}Expand description
Core task type representing a long-running operation
§Fields
task_id: Unique identifier (MUST be cryptographically secure)status: Current task statestatus_message: Optional human-readable status (any state)created_at: ISO 8601 timestamp of creationlast_updated_at: ISO 8601 timestamp when task was last updatedttl: Time-to-live in milliseconds from creation (null = unlimited)poll_interval: Suggested polling interval in milliseconds
§TTL Behavior
TTL is measured from created_at, not from last update:
Creation: 10:00:00, TTL: 60000ms (60s)
Expiry: 10:01:00 (regardless of updates)After TTL expiry, the receiver MAY delete the task and its results.
§Examples
use turbomcp_protocol::types::tasks::{Task, TaskStatus};
let task = Task {
task_id: "task-123".to_string(),
status: TaskStatus::Working,
status_message: Some("Processing data...".to_string()),
created_at: "2025-11-25T10:30:00Z".to_string(),
last_updated_at: "2025-11-25T10:30:00Z".to_string(),
ttl: Some(300_000), // 5 minutes
poll_interval: Some(5_000), // Poll every 5s
};
assert!(!task.status.is_terminal());
assert_eq!(task.ttl, Some(300_000));Fields§
§task_id: StringUnique identifier for this task
MUST be generated by receiver with cryptographic entropy (e.g., UUID v4). Task IDs are the primary access control mechanism.
status: TaskStatusCurrent task status
status_message: Option<String>Optional human-readable status message
Usage by status:
Cancelled: Reason for cancellationCompleted: Summary of resultsFailed: Diagnostic info, error detailsWorking/InputRequired: Progress updates
created_at: StringISO 8601 timestamp when task was created
Format: YYYY-MM-DDTHH:MM:SSZ (UTC)
TTL is measured from this timestamp.
last_updated_at: StringISO 8601 timestamp when task was last updated
Format: YYYY-MM-DDTHH:MM:SSZ (UTC)
Updated whenever task status or other fields change.
ttl: Option<u64>Time-to-live in milliseconds from creation
Some(ms): Task expires after this duration fromcreated_atNone: Unlimited retention (use with caution)
After expiry, receiver MAY delete task and results. Shorter TTLs improve security by reducing task ID exposure.
poll_interval: Option<u64>Suggested polling interval in milliseconds
Requestors SHOULD respect this value to avoid excessive polling. Receivers MAY adjust based on task complexity and load.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Task
impl<'de> Deserialize<'de> for Task
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Task
impl StructuralPartialEq for Task
Auto Trait Implementations§
impl Freeze for Task
impl RefUnwindSafe for Task
impl Send for Task
impl Sync for Task
impl Unpin for Task
impl UnwindSafe for Task
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.