MCPcopy Create free account
hub / github.com/MoonKraken/youtube / state_transition

Function state_transition

FullStackRust/backend/src/api/task.rs:94–119  ·  view source on GitHub ↗
(
    ddb_repo: Data<DDBRepository>, 
    task_global_id: String,
    new_state: TaskState,
    result_file: Option<String>
)

Source from the content-addressed store, hash-verified

92}
93
94async fn state_transition(
95 ddb_repo: Data<DDBRepository>,
96 task_global_id: String,
97 new_state: TaskState,
98 result_file: Option<String>
99) -> Result<Json<TaskIdentifier>, TaskError> {
100 let mut task = match ddb_repo.get_task(
101 task_global_id
102 ).await {
103 Some(task) => task,
104 None => return Err(TaskError::TaskNotFound)
105 };
106
107 if !task.can_transition_to(&new_state) {
108 return Err(TaskError::BadTaskRequest);
109 };
110
111 task.state = new_state;
112 task.result_file = result_file;
113
114 let task_identifier = task.get_global_id();
115 match ddb_repo.put_task(task).await {
116 Ok(()) => Ok(Json(TaskIdentifier { task_global_id: task_identifier })),
117 Err(_) => Err(TaskError::TaskUpdateFailure)
118 }
119}
120
121#[put("/task/{task_global_id}/start")]
122pub async fn start_task(

Callers 4

start_taskFunction · 0.70
pause_taskFunction · 0.70
fail_taskFunction · 0.70
complete_taskFunction · 0.70

Calls 4

get_taskMethod · 0.45
can_transition_toMethod · 0.45
get_global_idMethod · 0.45
put_taskMethod · 0.45

Tested by

no test coverage detected