Rullst AcademyRullst Academy/Lesson
Applications with Rullst I · Lesson 09 / 14

Complete without changing the target

A mission may change position; its id remains.

Learning paths18 min

Let's discover together

  1. 1

    PUT /api/missions/{id}/completion receives {"done":true} or false. Path extracts id and Completion requires a bool. UPDATE includes WHERE id = ?. Using screen position would change the wrong mission after reordering.

  2. 2

    Setting done=true twice keeps it true: the effect on that state is idempotent. Toggling done = !done twice returns to the start. This property comes from the implemented contract; writing PUT does not make every operation idempotent.

  3. 3

    The app checks rows_affected. A found record receives 204 with no body; a missing id receives 404 with an error. Do not parse JSON from 204: there is no content. Storage failure is a different situation and receives 503.

  4. 4

    The kit does not solve simultaneous editing between people. If two calls set different states, the last effective write wins. Record versions and concurrency control are deeper topics; state this limitation in your handoff.

Your application workbench

The kit includes a complete app to investigate and modify. The excerpt below explains this step; the editor contains the indicated file. Rullst Academy does not compile or run this server in your browser.

File to study and modify

src/routes.rs

PUT /api/missions/1/completion
{"done":true}

UPDATE missions SET done = ? WHERE id = ?

Extract the kit to a new folder and open a terminal beside Cargo.toml. Use Rust 1.96+; the first build may download dependencies and take time. Then open http://127.0.0.1:3010. Stop with Ctrl+C and run again after editing.

cargo test --locked
cargo run --locked
My files and GitHub

Download your draft and replace the indicated file in your extracted copy. The editor saves one file in this browser; your account saves assessments and XP. The ZIP excludes your edits. GitHub sends only the confirmed file; use Git manually for the whole app, excluding databases, backups and secrets.

Official links and next step

✦
YOUR MISSION

Update by id and distinguish idempotent assignment from toggling.

Now it's your turn

Discovery workshop

Decide before running

Update by id and distinguish idempotent assignment from toggling.
Build your answers and check when you are ready.
A moment to understand

Why does the handler use WHERE id = ?

I need a hint

Identifying the target does not authorize the actor. There are no accounts here; authorization is a later topic.

Loading your journey…

Take it with you

Repeat completion in the HTTP test and check state and count. Then test reopening with false. Explain the difference between setting and toggling in your own words.

At your own pace

My files and GitHub

Every lesson can become your own record: code, notes or a practice plan. Saving a file to GitHub is optional and does not change your XP.

Student guide

The editor and downloads open when this lesson is available to your account. Check access below or return to the track map.

Checking your access to this lesson…

Rullstpetbot

AI can make mistakes. Check the lesson material.