Closed CheetoTrump closed 9 months ago
better view of the code since github of all things dosnt have the code block working
my toml imports:
rand = "0.8.5" serde = { version = "1.0.196", features = ["derive"] } surrealdb = "1.1.1" tokio = { version = "1.35.1", features = ["macros", "rt-multi-thread"] } actix-web = "4.4.1" actix-session-surrealdb = "0.1.8" actix-session = "0.9.0"
it seems the docs.rs has the mostly correct code but the github and crates.io examples seem to be outdated/incorrect
So i took your example off of github and during compile i get these errors,
help: use("127.0.0.1:8000").await.unwrap();
| ++
::<...>
instead of<...>
to specify lifetime, type, or const arguments | 3 | let db = Surreal::new::error: expected one of("127.0.0.1:8000").await.unwrap();
| ^ expected one of
;
orelse
, found.
--> src\main.rs:3:48 | 3 | let db = Surreal::new;
orelse
error: unexpected token, expected
;
--> src\main.rs:6:13 | 6 | user: "root", | ^io
--> src\main.rs:2:20io
error[E0752]:
main
function is not allowed to beasync
--> src\main.rs:2:1 | 2 | async fn main() -> io::Result<()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^main
function is not allowed to beasync
Some errors have detailed explanations: E0433, E0752. For more information about an error, try
rustc --explain E0433
.from there i made the suggested edits:
added std::io, changed
let db = Surreal::new("127.0.0.1:8000").await.unwrap();
to
let db = Surreal::new::("127.0.0.1:8000").await.unwrap();
`use actix_web::cookie::time::Duration; use actix_web::cookie::Key; use surrealdb::opt::auth::Root; use std::io; use surrealdb::Surreal; use surrealdb::engine::remote::ws::Ws; use actix_web::HttpServer; use actix_web::App; use actix_session::SessionMiddleware; use actix_session::config::PersistentSession; use actix_session_surrealdb::SurrealSessionStore;
[actix_web::main]
async fn main() -> io::Result<()> { let db = Surreal::new::("127.0.0.1:8000").await.unwrap();
}`
current code^^^^
i get these errors
session_ttl_policy
found for structactix_session::config::PersistentSession
in the current scope --> src\main.rs:39:30session_ttl
(&str, &str): ToSocketAddrs
is not satisfied --> src\main.rs:45:11ToSocketAddrs
is not implemented for(&str, &str)
note: required by a bound in(mut self, addrs: A) -> io::Result {
| ^^^^^^^^^^^^^^^^^^ required by this bound in
HttpServer::<F, I, S, B>::bind
--> C:\Users\xboxk.cargo\registry\src\index.crates.io-1cd66030c949c28d\actix-web-4.4.1\src\server.rs:382:20 | 382 | pub fn bindHttpServer::<F, I, S, B>::bind
Some errors have detailed explanations: E0277, E0599. For more information about an error, try
rustc --explain E0277
.