Skip to content

Commit

Permalink
fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
lz1998 committed Dec 16, 2023
1 parent d2ab025 commit 8f3d3af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ publish = false

[dependencies]
axum = { path = "../../axum" }
futures-util = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = { version = "1.0", features = ["full"] }
Expand Down
13 changes: 7 additions & 6 deletions examples/error-handling-and-dependency-injection/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use axum::{
routing::{get, post},
Json, Router,
};
use futures_util::future::BoxFuture;
use serde::{Deserialize, Serialize};
use serde_json::json;
use std::sync::Arc;
Expand Down Expand Up @@ -109,12 +110,12 @@ impl IntoResponse for AppError {
struct ExampleUserRepo;

impl UserRepo for ExampleUserRepo {
async fn find(&self, _user_id: Uuid) -> Result<User, UserRepoError> {
unimplemented!()
fn find(&self, _user_id: Uuid) -> BoxFuture<Result<User, UserRepoError>> {
Box::pin(async { unimplemented!() })
}

async fn create(&self, _params: CreateUser) -> Result<User, UserRepoError> {
unimplemented!()
fn create(&self, _params: CreateUser) -> BoxFuture<Result<User, UserRepoError>> {
Box::pin(async { unimplemented!() })
}
}

Expand All @@ -124,10 +125,10 @@ type DynUserRepo = Arc<dyn UserRepo + Send + Sync>;
/// A trait that defines things a user repo might support.
trait UserRepo {
/// Loop up a user by their id.
async fn find(&self, user_id: Uuid) -> Result<User, UserRepoError>;
fn find(&self, user_id: Uuid) -> BoxFuture<Result<User, UserRepoError>>;

/// Create a new user.
async fn create(&self, params: CreateUser) -> Result<User, UserRepoError>;
fn create(&self, params: CreateUser) -> BoxFuture<Result<User, UserRepoError>>;
}

#[derive(Debug, Serialize)]
Expand Down

0 comments on commit 8f3d3af

Please sign in to comment.