From 552a57c2ffecce79fcab36d730d87d7ee2a608fc Mon Sep 17 00:00:00 2001 From: Brian Hardock Date: Wed, 22 Apr 2026 14:28:41 -0600 Subject: [PATCH] Update to Rust 2024 Signed-off-by: Brian Hardock --- .cargo/audit.toml | 1 + Cargo.toml | 2 +- crates/spin-sdk/src/http.rs | 2 +- crates/spin-sdk/src/http/body.rs | 2 +- crates/spin-sdk/src/http/grpc.rs | 8 +-- crates/spin-sdk/src/key_value.rs | 2 +- crates/spin-sdk/src/lib.rs | 9 ++- crates/spin-sdk/src/mysql.rs | 8 ++- crates/spin-sdk/src/pg.rs | 56 ++++++++++++------- crates/spin-sdk/src/test.rs | 4 +- examples/grpc/Cargo.toml | 2 +- examples/grpc/spin-dependencies.wit | 4 -- examples/grpc/src/lib.rs | 2 +- examples/hello-world/Cargo.toml | 2 +- examples/http-axum-router/Cargo.toml | 2 +- examples/http-axum-router/src/lib.rs | 2 +- .../http-concurrent-outbound-calls/Cargo.toml | 2 +- .../http-concurrent-outbound-calls/src/lib.rs | 4 +- examples/http-hello-world/Cargo.toml | 2 +- .../outbound-http-to-same-app/Cargo.toml | 2 +- .../outbound-http-to-same-app/src/lib.rs | 2 +- .../http-outbound/outbound-http/Cargo.toml | 2 +- .../http-outbound/outbound-http/src/lib.rs | 2 +- examples/http-send-request/Cargo.toml | 2 +- examples/http-send-request/src/lib.rs | 2 +- examples/http-streaming/Cargo.toml | 2 +- examples/http-streaming/src/lib.rs | 2 +- examples/key-value/Cargo.toml | 2 +- examples/key-value/src/lib.rs | 2 +- examples/mqtt-outbound/Cargo.toml | 2 +- examples/mysql/Cargo.toml | 2 +- examples/mysql/src/lib.rs | 4 +- examples/postgres/Cargo.toml | 2 +- examples/postgres/src/lib.rs | 2 +- examples/redis-outbound/Cargo.toml | 2 +- examples/redis-outbound/src/lib.rs | 2 +- examples/redis/Cargo.toml | 2 +- examples/server-sent-events/Cargo.toml | 2 +- examples/server-sent-events/src/lib.rs | 2 +- examples/sqlite/Cargo.toml | 2 +- examples/sqlite/src/lib.rs | 6 +- examples/variables/Cargo.toml | 2 +- 42 files changed, 90 insertions(+), 78 deletions(-) delete mode 100644 examples/grpc/spin-dependencies.wit diff --git a/.cargo/audit.toml b/.cargo/audit.toml index 3337ded..d23e2f4 100644 --- a/.cargo/audit.toml +++ b/.cargo/audit.toml @@ -1,4 +1,5 @@ [advisories] ignore = [ "RUSTSEC-2026-0097", + "RUSTSEC-2026-0104", ] diff --git a/Cargo.toml b/Cargo.toml index 6b6a96d..8059851 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ members = [ [workspace.package] version = "6.0.0" authors = ["Spin Framework Maintainers "] -edition = "2021" +edition = "2024" readme = "README.md" license = "Apache-2.0 WITH LLVM-exception" repository = "https://github.com/spinframework/spin-rust-sdk" diff --git a/crates/spin-sdk/src/http.rs b/crates/spin-sdk/src/http.rs index a6ba738..638eb60 100644 --- a/crates/spin-sdk/src/http.rs +++ b/crates/spin-sdk/src/http.rs @@ -521,7 +521,7 @@ impl IntoResponse for Json { #[cfg(feature = "json")] impl IntoResponse for (http::StatusCode, Json) { fn into_response(self) -> HttpResult { - let body = serde_json::to_vec(&self.1 .0) + let body = serde_json::to_vec(&self.1.0) .map_err(|e| types::ErrorCode::InternalError(Some(e.to_string())))?; let mut resp = http::Response::builder() .status(self.0) diff --git a/crates/spin-sdk/src/http/body.rs b/crates/spin-sdk/src/http/body.rs index 8c3b418..6517189 100644 --- a/crates/spin-sdk/src/http/body.rs +++ b/crates/spin-sdk/src/http/body.rs @@ -9,8 +9,8 @@ use bytes::Bytes; use futures::{ - channel::mpsc::{channel, Sender}, StreamExt, + channel::mpsc::{Sender, channel}, }; use http_body_util::{BodyDataStream, BodyExt}; use wasip3::{ diff --git a/crates/spin-sdk/src/http/grpc.rs b/crates/spin-sdk/src/http/grpc.rs index ae0d2e7..ca44458 100644 --- a/crates/spin-sdk/src/http/grpc.rs +++ b/crates/spin-sdk/src/http/grpc.rs @@ -49,10 +49,10 @@ use std::convert::Infallible; pub async fn serve(mut svc: S, req: crate::http::Request) -> http::Response where S: tower_service::Service< - crate::http::Request, - Response = http::Response, - Error = Infallible, - >, + crate::http::Request, + Response = http::Response, + Error = Infallible, + >, { // Infallible error — unwrap is safe. svc.call(req).await.unwrap_or_else(|e| match e {}) diff --git a/crates/spin-sdk/src/key_value.rs b/crates/spin-sdk/src/key_value.rs index 0afbe9a..6eaa2cd 100644 --- a/crates/spin-sdk/src/key_value.rs +++ b/crates/spin-sdk/src/key_value.rs @@ -38,7 +38,7 @@ pub mod wit { } #[cfg(feature = "json")] -use serde::{de::DeserializeOwned, Serialize}; +use serde::{Serialize, de::DeserializeOwned}; #[doc(inline)] pub use wit::key_value::Error; diff --git a/crates/spin-sdk/src/lib.rs b/crates/spin-sdk/src/lib.rs index b7e3221..087f4e8 100644 --- a/crates/spin-sdk/src/lib.rs +++ b/crates/spin-sdk/src/lib.rs @@ -63,14 +63,17 @@ pub mod time; #[cfg_attr(docsrs, doc(cfg(feature = "variables")))] pub mod variables; -#[export_name = concat!("spin-sdk-version-", env!("SDK_VERSION"))] +// SAFETY: There should only be a single definition of the spin-sdk-version-* symbol. +#[unsafe(export_name = concat!("spin-sdk-version-", env!("SDK_VERSION")))] extern "C" fn __spin_sdk_version() {} +// SAFETY: There should only be a single definition of the spin-sdk-language-rust symbol. #[cfg(feature = "export-sdk-language")] -#[export_name = "spin-sdk-language-rust"] +#[unsafe(export_name = "spin-sdk-language-rust")] extern "C" fn __spin_sdk_language() {} -#[export_name = concat!("spin-sdk-commit-", env!("SDK_COMMIT"))] +// SAFETY: There should only be a single definition of the spin-sdk-commit-* symbol. +#[unsafe(export_name = concat!("spin-sdk-commit-", env!("SDK_COMMIT")))] extern "C" fn __spin_sdk_hash() {} pub use wasip3::{self, wit_bindgen}; diff --git a/crates/spin-sdk/src/mysql.rs b/crates/spin-sdk/src/mysql.rs index 1b7d901..475b969 100644 --- a/crates/spin-sdk/src/mysql.rs +++ b/crates/spin-sdk/src/mysql.rs @@ -393,8 +393,10 @@ mod tests { ); assert!(String::decode(&DbValue::Int32(0)).is_err()); - assert!(Option::::decode(&DbValue::DbNull) - .unwrap() - .is_none()); + assert!( + Option::::decode(&DbValue::DbNull) + .unwrap() + .is_none() + ); } } diff --git a/crates/spin-sdk/src/pg.rs b/crates/spin-sdk/src/pg.rs index 6d0fac9..dfb3c86 100644 --- a/crates/spin-sdk/src/pg.rs +++ b/crates/spin-sdk/src/pg.rs @@ -1066,18 +1066,22 @@ mod tests { ); assert!(String::decode(&DbValue::Int32(0)).is_err()); - assert!(Option::::decode(&DbValue::DbNull) - .unwrap() - .is_none()); + assert!( + Option::::decode(&DbValue::DbNull) + .unwrap() + .is_none() + ); } #[test] fn binary() { assert!(Vec::::decode(&DbValue::Binary(vec![0, 0])).is_ok()); assert!(Vec::::decode(&DbValue::Boolean(false)).is_err()); - assert!(Option::>::decode(&DbValue::DbNull) - .unwrap() - .is_none()); + assert!( + Option::>::decode(&DbValue::DbNull) + .unwrap() + .is_none() + ); } #[test] @@ -1090,9 +1094,11 @@ mod tests { chrono::NaiveDate::decode(&DbValue::Date((1, 2, 4))).unwrap(), chrono::NaiveDate::from_ymd_opt(1, 2, 5).unwrap() ); - assert!(Option::::decode(&DbValue::DbNull) - .unwrap() - .is_none()); + assert!( + Option::::decode(&DbValue::DbNull) + .unwrap() + .is_none() + ); } #[test] @@ -1105,9 +1111,11 @@ mod tests { chrono::NaiveTime::decode(&DbValue::Time((1, 2, 3, 4))).unwrap(), chrono::NaiveTime::from_hms_nano_opt(1, 2, 4, 5).unwrap() ); - assert!(Option::::decode(&DbValue::DbNull) - .unwrap() - .is_none()); + assert!( + Option::::decode(&DbValue::DbNull) + .unwrap() + .is_none() + ); } #[test] @@ -1124,9 +1132,11 @@ mod tests { NaiveDateTime::decode(&DbValue::Datetime((1, 2, 3, 4, 5, 6, 7))).unwrap(), chrono::NaiveDateTime::new(date, time) ); - assert!(Option::::decode(&DbValue::DbNull) - .unwrap() - .is_none()); + assert!( + Option::::decode(&DbValue::DbNull) + .unwrap() + .is_none() + ); } #[test] @@ -1139,9 +1149,11 @@ mod tests { chrono::Duration::decode(&DbValue::Timestamp(2)).unwrap(), chrono::Duration::seconds(1) ); - assert!(Option::::decode(&DbValue::DbNull) - .unwrap() - .is_none()); + assert!( + Option::::decode(&DbValue::DbNull) + .unwrap() + .is_none() + ); } #[test] @@ -1152,9 +1164,11 @@ mod tests { uuid::Uuid::try_parse(uuid_str).unwrap(), uuid::Uuid::decode(&DbValue::Uuid(uuid_str.to_owned())).unwrap(), ); - assert!(Option::::decode(&DbValue::DbNull) - .unwrap() - .is_none()); + assert!( + Option::::decode(&DbValue::DbNull) + .unwrap() + .is_none() + ); } #[derive(Debug, serde::Deserialize, PartialEq)] diff --git a/crates/spin-sdk/src/test.rs b/crates/spin-sdk/src/test.rs index 0007e3b..f3f05a3 100644 --- a/crates/spin-sdk/src/test.rs +++ b/crates/spin-sdk/src/test.rs @@ -15,11 +15,11 @@ use { std::sync::OnceLock, tokio::{fs, process::Command}, wasmtime::{ - component::{Component, Linker, ResourceTable}, Config, Engine, Store, + component::{Component, Linker, ResourceTable}, }, wasmtime_wasi::{WasiCtx, WasiCtxBuilder, WasiCtxView, WasiView}, - wasmtime_wasi_http::{p3::WasiHttpView, WasiHttpCtx}, + wasmtime_wasi_http::{WasiHttpCtx, p3::WasiHttpView}, }; struct Ctx { diff --git a/examples/grpc/Cargo.toml b/examples/grpc/Cargo.toml index a505875..2f875c5 100644 --- a/examples/grpc/Cargo.toml +++ b/examples/grpc/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "grpc" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] crate-type = ["cdylib"] diff --git a/examples/grpc/spin-dependencies.wit b/examples/grpc/spin-dependencies.wit deleted file mode 100644 index b4548ab..0000000 --- a/examples/grpc/spin-dependencies.wit +++ /dev/null @@ -1,4 +0,0 @@ -package root:component; - -world root { -} diff --git a/examples/grpc/src/lib.rs b/examples/grpc/src/lib.rs index fc4861f..6dd2fc1 100644 --- a/examples/grpc/src/lib.rs +++ b/examples/grpc/src/lib.rs @@ -1,4 +1,4 @@ -use spin_sdk::http::{grpc, IntoResponse, Request}; +use spin_sdk::http::{IntoResponse, Request, grpc}; use spin_sdk::http_service; mod proto { diff --git a/examples/hello-world/Cargo.toml b/examples/hello-world/Cargo.toml index 8636a24..9905754 100644 --- a/examples/hello-world/Cargo.toml +++ b/examples/hello-world/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "hello-world" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] crate-type = ["cdylib"] diff --git a/examples/http-axum-router/Cargo.toml b/examples/http-axum-router/Cargo.toml index c6b4f4a..b76c598 100644 --- a/examples/http-axum-router/Cargo.toml +++ b/examples/http-axum-router/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "axum-router" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] crate-type = ["cdylib"] diff --git a/examples/http-axum-router/src/lib.rs b/examples/http-axum-router/src/lib.rs index 37e0aaf..d933f1a 100644 --- a/examples/http-axum-router/src/lib.rs +++ b/examples/http-axum-router/src/lib.rs @@ -1,7 +1,7 @@ use axum::{ + Json, Router, http::StatusCode, routing::{get, post}, - Json, Router, }; use serde::{Deserialize, Serialize}; use spin_sdk::http::{IntoResponse, Request}; diff --git a/examples/http-concurrent-outbound-calls/Cargo.toml b/examples/http-concurrent-outbound-calls/Cargo.toml index 0547281..a6a1285 100644 --- a/examples/http-concurrent-outbound-calls/Cargo.toml +++ b/examples/http-concurrent-outbound-calls/Cargo.toml @@ -4,7 +4,7 @@ authors = ["The Spin project"] description = "" version = "0.1.0" rust-version = "1.90" # required for `wasm32-wasip2` target to build WASIp3 -edition = "2021" +edition = "2024" [lib] crate-type = ["cdylib"] diff --git a/examples/http-concurrent-outbound-calls/src/lib.rs b/examples/http-concurrent-outbound-calls/src/lib.rs index 3140c54..e7ec077 100644 --- a/examples/http-concurrent-outbound-calls/src/lib.rs +++ b/examples/http-concurrent-outbound-calls/src/lib.rs @@ -1,9 +1,9 @@ use std::pin::pin; use std::time::{Duration, Instant}; -use futures::{channel::mpsc::Sender, SinkExt}; +use futures::{SinkExt, channel::mpsc::Sender}; use http::Request; -use spin_sdk::http::{body, send, EmptyBody, IntoResponse}; +use spin_sdk::http::{EmptyBody, IntoResponse, body, send}; use spin_sdk::http_service; // In this streaming scenario, the entry point is a shim diff --git a/examples/http-hello-world/Cargo.toml b/examples/http-hello-world/Cargo.toml index 669e25c..1c1758c 100644 --- a/examples/http-hello-world/Cargo.toml +++ b/examples/http-hello-world/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "wasip3-hello-world" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] crate-type = ["cdylib"] diff --git a/examples/http-outbound/outbound-http-to-same-app/Cargo.toml b/examples/http-outbound/outbound-http-to-same-app/Cargo.toml index c7f990a..1a6b0b1 100644 --- a/examples/http-outbound/outbound-http-to-same-app/Cargo.toml +++ b/examples/http-outbound/outbound-http-to-same-app/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "outbound-http-to-same-app" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] crate-type = ["cdylib"] diff --git a/examples/http-outbound/outbound-http-to-same-app/src/lib.rs b/examples/http-outbound/outbound-http-to-same-app/src/lib.rs index 2308166..eaf2457 100644 --- a/examples/http-outbound/outbound-http-to-same-app/src/lib.rs +++ b/examples/http-outbound/outbound-http-to-same-app/src/lib.rs @@ -1,6 +1,6 @@ use anyhow::Result; use spin_sdk::{ - http::{send, EmptyBody, IntoResponse, Request}, + http::{EmptyBody, IntoResponse, Request, send}, http_service, }; diff --git a/examples/http-outbound/outbound-http/Cargo.toml b/examples/http-outbound/outbound-http/Cargo.toml index a07156e..42a3756 100644 --- a/examples/http-outbound/outbound-http/Cargo.toml +++ b/examples/http-outbound/outbound-http/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "http-rust-outbound-http" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] crate-type = ["cdylib"] diff --git a/examples/http-outbound/outbound-http/src/lib.rs b/examples/http-outbound/outbound-http/src/lib.rs index 0ca8dca..6110c97 100644 --- a/examples/http-outbound/outbound-http/src/lib.rs +++ b/examples/http-outbound/outbound-http/src/lib.rs @@ -1,6 +1,6 @@ use anyhow::Result; use spin_sdk::{ - http::{send, EmptyBody, IntoResponse, Request, Response}, + http::{EmptyBody, IntoResponse, Request, Response, send}, http_service, }; diff --git a/examples/http-send-request/Cargo.toml b/examples/http-send-request/Cargo.toml index 02916e0..b66d4d1 100644 --- a/examples/http-send-request/Cargo.toml +++ b/examples/http-send-request/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "send-request" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] crate-type = ["cdylib"] diff --git a/examples/http-send-request/src/lib.rs b/examples/http-send-request/src/lib.rs index 034362a..5f2a1cd 100644 --- a/examples/http-send-request/src/lib.rs +++ b/examples/http-send-request/src/lib.rs @@ -1,4 +1,4 @@ -use spin_sdk::http::{send, EmptyBody, IntoResponse, Request, Result}; +use spin_sdk::http::{EmptyBody, IntoResponse, Request, Result, send}; use spin_sdk::http_service; /// Sends a request to a URL. diff --git a/examples/http-streaming/Cargo.toml b/examples/http-streaming/Cargo.toml index 1943a86..0845769 100644 --- a/examples/http-streaming/Cargo.toml +++ b/examples/http-streaming/Cargo.toml @@ -3,7 +3,7 @@ name = "streaming" description = "Demonstrates streaming processing of requests and responses" version = "0.1.0" rust-version = "1.90" -edition = "2021" +edition = "2024" [lib] crate-type = ["cdylib"] diff --git a/examples/http-streaming/src/lib.rs b/examples/http-streaming/src/lib.rs index 9d5003c..8a6bc56 100644 --- a/examples/http-streaming/src/lib.rs +++ b/examples/http-streaming/src/lib.rs @@ -1,5 +1,5 @@ use spin_sdk::http::body::IncomingBodyExt; -use spin_sdk::http::{body, IntoResponse, Request}; +use spin_sdk::http::{IntoResponse, Request, body}; use spin_sdk::http_service; use bytes::Bytes; diff --git a/examples/key-value/Cargo.toml b/examples/key-value/Cargo.toml index 6519a23..5a08e86 100644 --- a/examples/key-value/Cargo.toml +++ b/examples/key-value/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rust-key-value" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] crate-type = ["cdylib"] diff --git a/examples/key-value/src/lib.rs b/examples/key-value/src/lib.rs index cf1902f..61bc911 100644 --- a/examples/key-value/src/lib.rs +++ b/examples/key-value/src/lib.rs @@ -1,5 +1,5 @@ use bytes::Bytes; -use spin_sdk::http::{body::IncomingBodyExt, EmptyBody, FullBody, IntoResponse, Request}; +use spin_sdk::http::{EmptyBody, FullBody, IntoResponse, Request, body::IncomingBodyExt}; use spin_sdk::http_service; use spin_sdk::key_value::Store; diff --git a/examples/mqtt-outbound/Cargo.toml b/examples/mqtt-outbound/Cargo.toml index 8aa7678..aaeb1fb 100644 --- a/examples/mqtt-outbound/Cargo.toml +++ b/examples/mqtt-outbound/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rust-outbound-mqtt" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] crate-type = ["cdylib"] diff --git a/examples/mysql/Cargo.toml b/examples/mysql/Cargo.toml index 3d681ce..4bd327e 100644 --- a/examples/mysql/Cargo.toml +++ b/examples/mysql/Cargo.toml @@ -3,7 +3,7 @@ name = "rust-outbound-mysql" authors = ["The Spin authors"] description = "Demo of calling MySQL from a Spin application" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] crate-type = ["cdylib"] diff --git a/examples/mysql/src/lib.rs b/examples/mysql/src/lib.rs index e267987..308bad6 100644 --- a/examples/mysql/src/lib.rs +++ b/examples/mysql/src/lib.rs @@ -1,8 +1,8 @@ -use anyhow::{anyhow, Result}; +use anyhow::{Result, anyhow}; use bytes::Bytes; use http::{HeaderValue, Method, Response}; use spin_sdk::{ - http::{body::IncomingBodyExt, EmptyBody, FullBody, OptionalBody, Request}, + http::{EmptyBody, FullBody, OptionalBody, Request, body::IncomingBodyExt}, http_service, mysql::{self, ParameterValue}, }; diff --git a/examples/postgres/Cargo.toml b/examples/postgres/Cargo.toml index 1d2ccdc..51bfb20 100644 --- a/examples/postgres/Cargo.toml +++ b/examples/postgres/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rust-outbound-pg" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] crate-type = ["cdylib"] diff --git a/examples/postgres/src/lib.rs b/examples/postgres/src/lib.rs index fd6cdf4..0611196 100644 --- a/examples/postgres/src/lib.rs +++ b/examples/postgres/src/lib.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] use anyhow::Result; use futures::SinkExt; -use spin_sdk::http::{body, IntoResponse, Request}; +use spin_sdk::http::{IntoResponse, Request, body}; use spin_sdk::{http_service, pg}; // The environment variable set in `spin.toml` that points to the diff --git a/examples/redis-outbound/Cargo.toml b/examples/redis-outbound/Cargo.toml index b8266a9..e9a0941 100644 --- a/examples/redis-outbound/Cargo.toml +++ b/examples/redis-outbound/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rust-outbound-redis" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] crate-type = ["cdylib"] diff --git a/examples/redis-outbound/src/lib.rs b/examples/redis-outbound/src/lib.rs index be7bd4c..407fbac 100644 --- a/examples/redis-outbound/src/lib.rs +++ b/examples/redis-outbound/src/lib.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Context, Result}; +use anyhow::{Context, Result, anyhow}; use spin_sdk::http::{IntoResponse, Request}; use spin_sdk::http_service; use spin_sdk::redis; diff --git a/examples/redis/Cargo.toml b/examples/redis/Cargo.toml index 16e43f8..ca44604 100644 --- a/examples/redis/Cargo.toml +++ b/examples/redis/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "spin-redis" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] crate-type = [ "cdylib" ] diff --git a/examples/server-sent-events/Cargo.toml b/examples/server-sent-events/Cargo.toml index 13c9f5b..2d51fb2 100644 --- a/examples/server-sent-events/Cargo.toml +++ b/examples/server-sent-events/Cargo.toml @@ -3,7 +3,7 @@ name = "sse" description = "Demonstrates server-sent events" version = "0.1.0" rust-version = "1.90" -edition = "2021" +edition = "2024" [lib] crate-type = ["cdylib"] diff --git a/examples/server-sent-events/src/lib.rs b/examples/server-sent-events/src/lib.rs index 9112941..2f8234a 100644 --- a/examples/server-sent-events/src/lib.rs +++ b/examples/server-sent-events/src/lib.rs @@ -1,7 +1,7 @@ use std::time::Duration; use futures::channel::mpsc::Sender; -use spin_sdk::http::{body, IntoResponse, Request, Response}; +use spin_sdk::http::{IntoResponse, Request, Response, body}; use spin_sdk::http_service; use futures::SinkExt; diff --git a/examples/sqlite/Cargo.toml b/examples/sqlite/Cargo.toml index 5dbf42a..a942761 100644 --- a/examples/sqlite/Cargo.toml +++ b/examples/sqlite/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rust-sqlite" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] crate-type = ["cdylib"] diff --git a/examples/sqlite/src/lib.rs b/examples/sqlite/src/lib.rs index ab51a99..b7f0944 100644 --- a/examples/sqlite/src/lib.rs +++ b/examples/sqlite/src/lib.rs @@ -125,11 +125,7 @@ async fn list_users() -> Result> { fn extract_param(query: &str, key: &str) -> Option { query.split('&').find_map(|pair| { let (k, v) = pair.split_once('=')?; - if k == key { - Some(urldecode(v)) - } else { - None - } + if k == key { Some(urldecode(v)) } else { None } }) } diff --git a/examples/variables/Cargo.toml b/examples/variables/Cargo.toml index 202b358..49a9f21 100644 --- a/examples/variables/Cargo.toml +++ b/examples/variables/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "spin-variables-example" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] crate-type = ["cdylib"]