MCPcopy Create free account
hub / github.com/Rust-Web-Development/code / update_question

Function update_question

ch_04/final/src/main.rs:163–174  ·  view source on GitHub ↗
(
    id: String,
    store: Store,
    question: Question,
)

Source from the content-addressed store, hash-verified

161}
162
163async fn update_question(
164 id: String,
165 store: Store,
166 question: Question,
167) -> Result<impl warp::Reply, warp::Rejection> {
168 match store.questions.write().await.get_mut(&QuestionId(id)) {
169 Some(q) => *q = question,
170 None => return Err(warp::reject::custom(Error::QuestionNotFound)),
171 }
172
173 Ok(warp::reply::with_status("Question updated", StatusCode::OK))
174}
175
176async fn delete_question(id: String, store: Store) -> Result<impl warp::Reply, warp::Rejection> {
177 match store.questions.write().await.remove(&QuestionId(id)) {

Callers

nothing calls this directly

Calls 1

QuestionIdClass · 0.70

Tested by

no test coverage detected