Type Alias PayloadJson

Source
pub type PayloadJson<T> = Result<Json<T>, JsonRejection>;
Expand description

This type is used when you have a JSON request body as it can potentially throw [JsonRejection], which is not handled by serde_json.

See this example when using in a handler:

async fn update_user_base(payload: PayloadJson<UserUpdate>) -> Result<Json<UserUpdate>> {
    Json(user) = payload?;
    println!("User ID: {user.id}");
}

Aliased Type§

enum PayloadJson<T> {
    Ok(Json<T>),
    Err(JsonRejection),
}

Variants§

§1.0.0

Ok(Json<T>)

Contains the success value

§1.0.0

Err(JsonRejection)

Contains the error value