Skip to content

Commit f2cd046

Browse files
committed
update wit_bindgen to latest version
1 parent 3642e4d commit f2cd046

File tree

10 files changed

+32
-38
lines changed

10 files changed

+32
-38
lines changed

Cargo.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
members = ["derive", ".", "examples/*"]
33

44
[workspace.package]
5-
version = "0.1.4"
5+
version = "0.1.5"
66
edition = "2021"
77
license = "Apache-2.0"
88
publish = false
@@ -25,13 +25,14 @@ json = ["serde_json"]
2525

2626
[dependencies]
2727
fastedge-derive = { path = "derive" }
28-
http = "^0.2"
28+
http = "1.1.0"
2929
bytes = "^1.5"
30-
wit-bindgen = "^0.9"
30+
wit-bindgen = "0.24.0"
3131
thiserror = "^1.0"
3232
tracing = "^0.1"
3333
mime = "^0.3"
3434
serde_json = { version = "^1.0", optional = true }
3535

3636
[dev-dependencies]
3737
anyhow = "1.0"
38+

derive/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ pub fn http(_attr: TokenStream, item: TokenStream) -> TokenStream {
2727
let func_name = &func.sig.ident;
2828

2929
quote!(
30-
use fastedge::bindgen::__link_section;
31-
use fastedge::bindgen::exports;
32-
30+
use fastedge::http_handler::Guest;
3331
struct Component;
34-
fastedge::export_http_reactor!(Component);
3532

3633
#[inline(always)]
3734
fn internal_error(body: &str) -> ::fastedge::http_handler::Response {
@@ -46,7 +43,7 @@ pub fn http(_attr: TokenStream, item: TokenStream) -> TokenStream {
4643
#[no_mangle]
4744
#func
4845

49-
impl ::fastedge::http_handler::HttpHandler for Component {
46+
impl Guest for Component {
5047
#[no_mangle]
5148
fn process(req: ::fastedge::http_handler::Request) -> ::fastedge::http_handler::Response {
5249

@@ -68,5 +65,8 @@ pub fn http(_attr: TokenStream, item: TokenStream) -> TokenStream {
6865
}
6966
}
7067

68+
fastedge::export!(Component with_types_in fastedge);
69+
70+
7171
).into()
7272
}

examples/classification-nn-demo/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use fastedge::wasi_nn::wasi::nn::inference;
1212
use fastedge::wasi_nn::wasi::nn::tensor;
1313

1414
use crate::imagenet_classes::IMAGENET_CLASSES;
15-
use fastedge::wasi_nn::wasi::nn::inference::{GraphExecutionContext, TensorData};
15+
use fastedge::wasi_nn::wasi::nn::inference::{GraphExecutionContext};
1616

1717
#[allow(dead_code)]
1818
mod image2tensor;
@@ -104,7 +104,7 @@ fn main(req: Request<Body>) -> Result<Response<Body>, Error> {
104104
}
105105

106106
/// perform inference
107-
fn inference(model_name: Cow<str>, input: &[u8]) -> Result<TensorData, inference::Error> {
107+
fn inference(model_name: Cow<str>, input: &[u8]) -> Result<tensor::TensorData, inference::Error> {
108108
//load graph by name already loaded and initialized in FastEdge runtime
109109
let graph_handle = graph::load_by_name(&model_name)?;
110110
let context = inference::init_execution_context(graph_handle)?;

src/http_client.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
use http::request::Parts;
55

6-
use crate::bindgen::gcore::fastedge::{http::Method, http_client};
6+
use crate::gcore::fastedge::{http::Method, http_client};
77
use crate::body::Body;
88
use crate::Error;
99

src/lib.rs

+7-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
/*
22
* Copyright 2024 G-Core Innovations SARL
33
*/
4-
#![deny(missing_docs)]
5-
//#![deny(elided_lifetimes_in_paths)]
6-
74
//! # Rust SDK for FastEdge.
85
96
pub extern crate http;
107

118
pub use fastedge_derive::http;
12-
139
pub use http_client::send_request;
1410

15-
pub use crate::bindgen::exports::gcore::fastedge::http_handler;
16-
use crate::bindgen::gcore::fastedge::http::{Error as HttpError, Method, Request, Response};
11+
pub use crate::exports::gcore::fastedge::http_handler;
12+
use crate::gcore::fastedge::http::{Error as HttpError, Method, Request, Response};
1713

1814
/// Implementation of Outbound HTTP component
1915
mod http_client;
@@ -26,14 +22,11 @@ pub mod wasi_nn {
2622
});
2723
}
2824

29-
pub mod bindgen {
30-
#![allow(missing_docs)]
31-
wit_bindgen::generate!({
32-
world: "http-reactor",
33-
path: "wit",
34-
macro_export
35-
});
36-
}
25+
wit_bindgen::generate!({
26+
world: "http-reactor",
27+
path: "wit",
28+
pub_export_macro: true
29+
});
3730

3831
/// Error type returned by [`send_request`][crate::bindgen::gcore::fastedge::http_client::send_request]
3932
#[derive(thiserror::Error, Debug)]

wit/http-client.wit

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
interface http-client {
2-
use http.{request, response, error}
2+
use http.{request, response, error};
33

4-
send-request: func(req: request) -> result<response, error>
4+
send-request: func(req: request) -> result<response, error>;
55
}

wit/http-handler.wit

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
interface http-handler {
2-
use http.{request, response}
3-
process: func(req: request) -> response
2+
use http.{request, response};
3+
process: func(req: request) -> response;
44
}

wit/http.wit

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
interface http {
2-
type http-status = u16
3-
type body = list<u8>
4-
type headers = list<tuple<string, string>>
5-
type uri = string
2+
type http-status = u16;
3+
type body = list<u8>;
4+
type headers = list<tuple<string, string>>;
5+
type uri = string;
66

77
enum method {
88
get,

wit/world.wit

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package gcore:fastedge
1+
package gcore:fastedge;
22

33
world http-reactor {
4-
import http
5-
import http-client
4+
import http;
5+
import http-client;
66

7-
export http-handler
7+
export http-handler;
88
}

0 commit comments

Comments
 (0)