最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

rust - Unresolved import `self::ssr` in Leptos example - Stack Overflow

programmeradmin2浏览0评论

I'm looking at the leptos example 'todo_app_sqlite_axum'.

In todo.rs, the function 'get_todos' has an import statement

use self::ssr::*;

error is

error[E0432]: unresolved import `self::ssr`
  --> src/todo.rs:96:15
   |
96 |     use self::ssr::*;
   |               ^^^ could not find `ssr` in `self`

I'm looking at the leptos example 'todo_app_sqlite_axum'.

https://github/leptos-rs/leptos/tree/main/examples/todo_app_sqlite_axum

In todo.rs, the function 'get_todos' has an import statement

use self::ssr::*;

error is

error[E0432]: unresolved import `self::ssr`
  --> src/todo.rs:96:15
   |
96 |     use self::ssr::*;
   |               ^^^ could not find `ssr` in `self`

Share Improve this question asked Feb 16 at 16:07 W4t3randWindW4t3randWind 6651 gold badge7 silver badges16 bronze badges 1
  • Have you enabled the ssr feature? – Jmb Commented Feb 16 at 16:40
Add a comment  | 

1 Answer 1

Reset to default 0

todo.rs includes a ssr module, but it is feature-gated by "ssr":

#[cfg(feature = "ssr")]
pub mod ssr {
    // use http::{header::SET_COOKIE, HeaderMap, HeaderValue, StatusCode};
    use leptos::server_fn::ServerFnError;
    use sqlx::{Connection, SqliteConnection};

    pub async fn db() -> Result<SqliteConnection, ServerFnError> {
        Ok(SqliteConnection::connect("sqlite:Todos.db").await?)
    }
}

The #[server] functions that use self::ssr::* are not similarly feature-gated.

Anyway, you should be able to run the example by enabling the feature:

cargo run --example todo_app_sqlite_axum --features ssr

There are some SSR notes in the examples folder but I would probably file an issue.

发布评论

评论列表(0)

  1. 暂无评论