Skip to content

Commit

Permalink
allow some type dup to avoid deps
Browse files Browse the repository at this point in the history
  • Loading branch information
StuartHarris committed Sep 23, 2024
1 parent 32d3b1a commit 8887b62
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 13 deletions.
2 changes: 0 additions & 2 deletions wasm-components/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wasm-components/rust/data-init/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ crate-type = ["cdylib"]
[dependencies]
serde.workspace = true
serde_json.workspace = true
uuid = { version = "1.10.0", features = ["v4"] }
uuid = { workspace = true, features = ["v4"] }
wit-bindgen.workspace = true
1 change: 0 additions & 1 deletion wasm-components/rust/http-controller/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ crate-type = ["cdylib"]
[dependencies]
anyhow.workspace = true
form_urlencoded = "1.2.1"
products-service = { version = "0.1.0", path = "../products-service" }
routefinder = "0.5.4"
serde.workspace = true
uuid = { workspace = true, features = ["v4", "serde"] }
Expand Down
10 changes: 9 additions & 1 deletion wasm-components/rust/http-controller/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ wit_bindgen::generate!({
generate_all,
});

use products_service::SerializableProduct;
use routefinder::Router;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
Expand Down Expand Up @@ -353,6 +352,15 @@ struct SerializableOrder {
total: Pence,
}

#[derive(Serialize, Deserialize)]
pub struct SerializableProduct {
pub id: Uuid,
pub name: String,
pub description: String,
pub price: i32,
pub sku: String,
}

impl TryFrom<&Product> for SerializableProduct {
type Error = anyhow::Error;

Expand Down
2 changes: 1 addition & 1 deletion wasm-components/rust/notification-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
version = "0.1.0"

[lib]
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib"]

[dependencies]
serde.workspace = true
Expand Down
6 changes: 2 additions & 4 deletions wasm-components/rust/notification-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ use serde::{Deserialize, Serialize};
use exports::wasmcloud::messaging::handler::{BrokerMessage, Guest};
use wasi::logging::logging::{log, Level};

pub const NOTIFICATION_SUBJECT: &str = "platform-poc.order-notification";

struct Component;
export!(Component);

Expand Down Expand Up @@ -46,6 +44,6 @@ fn loud_print(msg: &str, data: &str) {
}

#[derive(Serialize, Deserialize, Default)]
pub struct OrderNotification {
pub order_number: String,
struct OrderNotification {
order_number: String,
}
1 change: 0 additions & 1 deletion wasm-components/rust/orders-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ crate-type = ["cdylib"]

[dependencies]
indoc = "2.0.5"
notification-service = { version = "0.1.0", path = "../notification-service" }
serde.workspace = true
serde_json.workspace = true
uuid = { workspace = true, features = ["v4"] }
Expand Down
9 changes: 8 additions & 1 deletion wasm-components/rust/orders-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ wit_bindgen::generate!({
generate_all,
});

use notification_service::{OrderNotification, NOTIFICATION_SUBJECT};
use std::collections::HashMap;

use indoc::indoc;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

use exports::platform_poc::orders::orders::Guest;
Expand All @@ -31,6 +31,8 @@ use wasmcloud::{
},
};

const NOTIFICATION_SUBJECT: &str = "platform-poc.order-notification";

struct Component;
export!(Component);

Expand Down Expand Up @@ -209,3 +211,8 @@ impl Guest for Component {
Ok(orders)
}
}

#[derive(Serialize, Deserialize, Default)]
struct OrderNotification {
pub order_number: String,
}
2 changes: 1 addition & 1 deletion wasm-components/rust/products-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ edition = "2021"
version = "0.1.0"

[lib]
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib"]

[dependencies]
anyhow.workspace = true
Expand Down

0 comments on commit 8887b62

Please sign in to comment.