Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cargo/audit.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[advisories]
ignore = [
"RUSTSEC-2026-0097",
"RUSTSEC-2026-0104",
]
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ members = [
[workspace.package]
version = "6.0.0"
authors = ["Spin Framework Maintainers <cncf-spin-maintainers@lists.cncf.io>"]
edition = "2021"
edition = "2024"
readme = "README.md"
license = "Apache-2.0 WITH LLVM-exception"
repository = "https://github.com/spinframework/spin-rust-sdk"
Expand Down
2 changes: 1 addition & 1 deletion crates/spin-sdk/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ impl<T: serde::Serialize> IntoResponse for Json<T> {
#[cfg(feature = "json")]
impl<T: serde::Serialize> IntoResponse for (http::StatusCode, Json<T>) {
fn into_response(self) -> HttpResult<types::Response> {
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)
Expand Down
2 changes: 1 addition & 1 deletion crates/spin-sdk/src/http/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
8 changes: 4 additions & 4 deletions crates/spin-sdk/src/http/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ use std::convert::Infallible;
pub async fn serve<S, B>(mut svc: S, req: crate::http::Request) -> http::Response<B>
where
S: tower_service::Service<
crate::http::Request,
Response = http::Response<B>,
Error = Infallible,
>,
crate::http::Request,
Response = http::Response<B>,
Error = Infallible,
>,
{
// Infallible error — unwrap is safe.
svc.call(req).await.unwrap_or_else(|e| match e {})
Expand Down
2 changes: 1 addition & 1 deletion crates/spin-sdk/src/key_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions crates/spin-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")))]
Comment thread
fibonacci1729 marked this conversation as resolved.
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};
Expand Down
8 changes: 5 additions & 3 deletions crates/spin-sdk/src/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,10 @@ mod tests {
);

assert!(String::decode(&DbValue::Int32(0)).is_err());
assert!(Option::<String>::decode(&DbValue::DbNull)
.unwrap()
.is_none());
assert!(
Option::<String>::decode(&DbValue::DbNull)
.unwrap()
.is_none()
);
}
}
56 changes: 35 additions & 21 deletions crates/spin-sdk/src/pg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1066,18 +1066,22 @@ mod tests {
);

assert!(String::decode(&DbValue::Int32(0)).is_err());
assert!(Option::<String>::decode(&DbValue::DbNull)
.unwrap()
.is_none());
assert!(
Option::<String>::decode(&DbValue::DbNull)
.unwrap()
.is_none()
);
}

#[test]
fn binary() {
assert!(Vec::<u8>::decode(&DbValue::Binary(vec![0, 0])).is_ok());
assert!(Vec::<u8>::decode(&DbValue::Boolean(false)).is_err());
assert!(Option::<Vec<u8>>::decode(&DbValue::DbNull)
.unwrap()
.is_none());
assert!(
Option::<Vec<u8>>::decode(&DbValue::DbNull)
.unwrap()
.is_none()
);
}

#[test]
Expand All @@ -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::<chrono::NaiveDate>::decode(&DbValue::DbNull)
.unwrap()
.is_none());
assert!(
Option::<chrono::NaiveDate>::decode(&DbValue::DbNull)
.unwrap()
.is_none()
);
}

#[test]
Expand All @@ -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::<chrono::NaiveTime>::decode(&DbValue::DbNull)
.unwrap()
.is_none());
assert!(
Option::<chrono::NaiveTime>::decode(&DbValue::DbNull)
.unwrap()
.is_none()
);
}

#[test]
Expand All @@ -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::<chrono::NaiveDateTime>::decode(&DbValue::DbNull)
.unwrap()
.is_none());
assert!(
Option::<chrono::NaiveDateTime>::decode(&DbValue::DbNull)
.unwrap()
.is_none()
);
}

#[test]
Expand All @@ -1139,9 +1149,11 @@ mod tests {
chrono::Duration::decode(&DbValue::Timestamp(2)).unwrap(),
chrono::Duration::seconds(1)
);
assert!(Option::<chrono::Duration>::decode(&DbValue::DbNull)
.unwrap()
.is_none());
assert!(
Option::<chrono::Duration>::decode(&DbValue::DbNull)
.unwrap()
.is_none()
);
}

#[test]
Expand All @@ -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::<uuid::Uuid>::decode(&DbValue::DbNull)
.unwrap()
.is_none());
assert!(
Option::<uuid::Uuid>::decode(&DbValue::DbNull)
.unwrap()
.is_none()
);
}

#[derive(Debug, serde::Deserialize, PartialEq)]
Expand Down
4 changes: 2 additions & 2 deletions crates/spin-sdk/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion examples/grpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "grpc"
version = "0.1.0"
edition = "2021"
edition = "2024"

[lib]
crate-type = ["cdylib"]
Expand Down
4 changes: 0 additions & 4 deletions examples/grpc/spin-dependencies.wit

This file was deleted.

2 changes: 1 addition & 1 deletion examples/grpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion examples/hello-world/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "hello-world"
version = "0.1.0"
edition = "2021"
edition = "2024"

[lib]
crate-type = ["cdylib"]
Expand Down
2 changes: 1 addition & 1 deletion examples/http-axum-router/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "axum-router"
version = "0.1.0"
edition = "2021"
edition = "2024"

[lib]
crate-type = ["cdylib"]
Expand Down
2 changes: 1 addition & 1 deletion examples/http-axum-router/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
2 changes: 1 addition & 1 deletion examples/http-concurrent-outbound-calls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
4 changes: 2 additions & 2 deletions examples/http-concurrent-outbound-calls/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/http-hello-world/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "wasip3-hello-world"
version = "0.1.0"
edition = "2021"
edition = "2024"

[lib]
crate-type = ["cdylib"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "outbound-http-to-same-app"
version = "0.1.0"
edition = "2021"
edition = "2024"

[lib]
crate-type = ["cdylib"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Result;
use spin_sdk::{
http::{send, EmptyBody, IntoResponse, Request},
http::{EmptyBody, IntoResponse, Request, send},
http_service,
};

Expand Down
2 changes: 1 addition & 1 deletion examples/http-outbound/outbound-http/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "http-rust-outbound-http"
version = "0.1.0"
edition = "2021"
edition = "2024"

[lib]
crate-type = ["cdylib"]
Expand Down
2 changes: 1 addition & 1 deletion examples/http-outbound/outbound-http/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Result;
use spin_sdk::{
http::{send, EmptyBody, IntoResponse, Request, Response},
http::{EmptyBody, IntoResponse, Request, Response, send},
http_service,
};

Expand Down
2 changes: 1 addition & 1 deletion examples/http-send-request/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "send-request"
version = "0.1.0"
edition = "2021"
edition = "2024"

[lib]
crate-type = ["cdylib"]
Expand Down
2 changes: 1 addition & 1 deletion examples/http-send-request/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/http-streaming/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion examples/http-streaming/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/key-value/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rust-key-value"
version = "0.1.0"
edition = "2021"
edition = "2024"

[lib]
crate-type = ["cdylib"]
Expand Down
2 changes: 1 addition & 1 deletion examples/key-value/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion examples/mqtt-outbound/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rust-outbound-mqtt"
version = "0.1.0"
edition = "2021"
edition = "2024"

[lib]
crate-type = ["cdylib"]
Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
4 changes: 2 additions & 2 deletions examples/mysql/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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},
};
Expand Down
Loading
Loading