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

Function add_question

ch_04/final/src/main.rs:143–161  ·  view source on GitHub ↗
(
    store: Store,
    new_question: NewQuestion,
)

Source from the content-addressed store, hash-verified

141}
142
143async fn add_question(
144 store: Store,
145 new_question: NewQuestion,
146) -> Result<impl warp::Reply, warp::Rejection> {
147 let question = Question {
148 id: QuestionId(format!("q-{}", store.questions.read().await.len() + 1)),
149 title: new_question.title,
150 content: new_question.content,
151 tags: new_question.tags,
152 };
153
154 store
155 .questions
156 .write()
157 .await
158 .insert(question.id.clone(), question);
159
160 Ok(warp::reply::with_status("Question added", StatusCode::OK))
161}
162
163async fn update_question(
164 id: String,

Callers

nothing calls this directly

Calls 1

QuestionIdClass · 0.70

Tested by

no test coverage detected