I am trying to use the axum-login
crate and I am following the documentation found here. I have copied the code code and I am getting an error that I don't understand.
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Session layer.
let session_store = MemoryStore::default();
let session_layer = SessionManagerLayer::new(session_store);
// Auth service.
let backend = Backend::default();
let auth_layer = AuthManagerLayerBuilder::new(backend, session_layer).build();
let app = Router::new()
.route("/protected", get(todo!()))
.route_layer(login_required!(Backend, login_url = "/login"))
.route("/login", post(todo!()))
.route("/login", get(todo!()))
.layer(auth_layer); <- GETTING ERROR HERE ******
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app.into_make_service()).await?;
Ok(())
}
the trait bound `Infallible: From<Box<(dyn std::error::Error + Send + Sync + 'static)>>` is not satisfied
Can someone with experience using this lend me a hand in trying to figure out what the problem is? The other example provided by the documentation is way too complicated for me to even start wrapping my head around and I can't seem to find an example where someone has used it.
It compiles with Rust 1.75.0 with:
[dependencies]
axum-login = "0.13.1"
axum = "0.7.4"
tokio = { version = "1", features = ["full"] }
async-trait = "0.1.77"
Maybe you have to update dependencies or your Rust compiler / platform.