oxidlabs / tera-hot-reload

MIT License
1 stars 0 forks source link

unresolved import `notify_debouncer_full::notify::ReadDirectoryChangesWatcher` #1

Open watery-desert opened 11 hours ago

watery-desert commented 11 hours ago

Thanks for this library, I am the guy from reddit, I can't compile it, I get error,

   Compiling tera-hot-reload v0.2.0
error[E0432]: unresolved import `notify_debouncer_full::notify::ReadDirectoryChangesWatcher`
   --> /Users/ahmed/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tera-hot-reload-0.2.0/src/lib.rs:10:5
    |
10  |     ReadDirectoryChangesWatcher, 
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `ReadDirectoryChangesWatcher` in the root
    |
note: found an item that was configured out
   --> /Users/ahmed/.cargo/registry/src/index.crates.io-6f17d22bba15001f/notify-6.1.1/src/lib.rs:228:18
    |
228 | pub use windows::ReadDirectoryChangesWatcher;
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: the item is gated behind the `windows` feature
   --> /Users/ahmed/.cargo/registry/src/index.crates.io-6f17d22bba15001f/notify-6.1.1/src/lib.rs:227:7
    |
227 | #[cfg(target_os = "windows")]
    | 

Here is my code, mostly copied from example app, and applied on a dummy project.

use axum::{
    response::{Html, IntoResponse, Response},
    routing::get,
    Router,
};
use serde::Serialize;

use tera::{Context, Tera};

use std::time::Duration;
use tera_hot_reload::TeraTemplate;
use tera_hot_reload::{watch, LiveReloadLayer, TeraTemplate};

#[tokio::main]
async fn main() {
    let livereload = LiveReloadLayer::new();
    let reloader = livereload.reloader();

    let listener = tokio::net::TcpListener::bind("127.0.0.1:9000")
        .await
        .unwrap();

    let app = Router::new().route("/", get(home_handler)).layer(reloader);

    let _debouncer = watch(
        move || reloader.reload(),
        Duration::from_millis(10),
        vec!["./templates"],
    );

    axum::serve(listener, app).await.unwrap()
}

async fn home_handler() -> Response {
    let context = HomeTemplate {};

    Html(context.render()).into_response()
}

#[derive(TeraTemplate, Serialize)]
#[template(path = "pages/home.html")]
struct HomeTemplate {}

here is my folder structure

templates/
    ├── index.html
    ├── partials/
    │   └── nav.html
    └── pages/
        └── home.html
Tebarem commented 2 hours ago

Hey mate sorry for the late reply. I will have a look. I think its the cargo.lock but not entirely sure. I didnt get an email when you submitted this issue weirdly.