diff --git a/.gitmodules b/.gitmodules index e469355c..541b2bfe 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ -[submodule "opendigitaltwins-dtdl"] - path = opendigitaltwins-dtdl +[submodule "external/opendigitaltwins-dtdl"] + path = external/opendigitaltwins-dtdl url = https://github.com/Azure/opendigitaltwins-dtdl -[submodule "iot-plugandplay-models"] - path = iot-plugandplay-models +[submodule "external/iot-plugandplay-models"] + path = external/iot-plugandplay-models url = https://github.com/Azure/iot-plugandplay-models diff --git a/Cargo.toml b/Cargo.toml index 5c8d8fc5..9d3e4c6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,19 +5,22 @@ [workspace] members = [ - "common", - "common-test", + # core + "core/protobuf_data_access", + "core/in-vehicle-digital-twin", + + # digital twin model "digital-twin-model", + + # DTDL parser "dtdl-parser", - "in-vehicle-digital-twin", + + # samples "samples/common", - "samples/proto", - "samples/command/consumer", - "samples/command/provider", - "samples/mixed/consumer", - "samples/mixed/provider", - "samples/property/consumer", - "samples/property/provider" + "samples/protobuf_data_access", + "samples/command", + "samples/mixed", + "samples/property", ] [workspace.dependencies] diff --git a/common-test/Cargo.toml b/common-test/Cargo.toml deleted file mode 100644 index 9c117773..00000000 --- a/common-test/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT license. -# SPDX-License-Identifier: MIT - -[package] -name = "ibeji-common_test" -version = "0.1.0" -edition = "2021" -license = "MIT" - -[dependencies] -log = { workspace = true} \ No newline at end of file diff --git a/common-test/src/lib.rs b/common-test/src/lib.rs deleted file mode 100644 index 2d6521b7..00000000 --- a/common-test/src/lib.rs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -// SPDX-License-Identifier: MIT - -use log::{trace, warn}; -use std::env; -use std::path::Path; - -/// The DTDL-path environment variable name. -pub const DTDL_PATH: &str = "DTDL_PATH"; - -/// The DTDL-path environment variable name. -pub const CARGO_MANIFEST_DIR: &str = "CARGO_MANIFEST_DIR"; - -/// Get the repository's directory. -fn get_repo_dir() -> Option { - // CARGO_MANIFEST_DIR - The directory containing the manifest of your package. - let cargo_manifest_dir_result = env::var(CARGO_MANIFEST_DIR); - if let Ok(cargo_manifest_dir) = cargo_manifest_dir_result { - let cargo_manifest_dir_path = Path::new(&cargo_manifest_dir); - let parent_result = cargo_manifest_dir_path.parent(); - if let Some(parent) = parent_result { - parent.to_str().map(String::from) - } else { - None - } - } else { - None - } -} - -/// Set the DTDL_PATH environment, so that the tests can use it. -pub fn set_dtdl_path() { - let repo_dir_result = get_repo_dir(); - if let Some(repo_dir) = repo_dir_result { - let value = format!( - "{repo_dir}/opendigitaltwins-dtdl/DTDL;{repo_dir}/iot-plugandplay-models;{repo_dir}/dtdl;{repo_dir}/digital-twin-model/dtdl" - ); - env::set_var(DTDL_PATH, &value); - trace!("{DTDL_PATH}={value}"); - } else { - warn!("Unable to set {DTDL_PATH}, as repo directory could not be determined."); - } -} - -#[cfg(test)] -mod ibeji_common_test_tests { - use super::*; - use std::env; - - #[test] - fn find_by_id_test() { - env::remove_var(DTDL_PATH); - set_dtdl_path(); - let get_dtdl_path_result = env::var(DTDL_PATH); - assert!(get_dtdl_path_result.is_ok()); - let dtdl_path = get_dtdl_path_result.unwrap(); - assert!(!dtdl_path.is_empty()); - assert!(dtdl_path.contains("/opendigitaltwins-dtdl/DTDL")); - assert!(dtdl_path.contains("/dtdl")); - } -} diff --git a/common/Cargo.toml b/common/Cargo.toml deleted file mode 100644 index 520d2973..00000000 --- a/common/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT license. -# SPDX-License-Identifier: MIT - -[package] -name = "ibeji-common" -version = "0.1.0" -edition = "2021" -license = "MIT" - -[dependencies] -ibeji-common_test = { path = "../common-test" } \ No newline at end of file diff --git a/common/src/lib.rs b/common/src/lib.rs deleted file mode 100644 index 1e55194f..00000000 --- a/common/src/lib.rs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -// SPDX-License-Identifier: MIT - -use std::env; -use std::fs; -use std::path::Path; - -/// The DTDL-path environment variable name. -pub const DTDL_PATH: &str = "DTDL_PATH"; - -/// Find the full path given a relative path and a preset DTDL_PATH environment variable (containing a semicolon-separated list of DTDL directories). -/// -/// # Arguments -/// `relative_path` - The relative path. -pub fn find_full_path(relative_path: &str) -> Result { - match env::var(DTDL_PATH) { - Ok(paths) => { - let split = paths.split(';'); - let vec: Vec<&str> = split.collect(); - for path in vec { - let full_path = Path::new(path).join(relative_path); - if full_path.exists() { - return Ok(full_path.to_str().unwrap().to_string()); - } - } - } - Err(_) => { - return Err(String::from( - "Unable to get the environment variable DTDL_PATH. Please set it.", - )) - } - } - Err(String::from("Unable to resolve the full path")) -} - -/// Retrieve the contents of the DTDL from the specified file path. -/// -/// # Arguments: -/// `file_path` - The file path where the DTDL is located. -pub fn retrieve_dtdl(file_path: &str) -> Result { - let path = Path::new(file_path); - let read_result = fs::read_to_string(path); - match read_result { - Ok(contents) => Ok(contents), - Err(error) => Err(format!("Unable to retrieve the DTDL due to: {error}")), - } -} - -#[cfg(test)] -mod ibeji_common_tests { - use super::*; - use ibeji_common_test::set_dtdl_path; - - #[test] - fn find_full_path_test() { - set_dtdl_path(); - - let find_full_path_result = find_full_path("v2/content/sdv/vehicle.json"); - assert!(find_full_path_result.is_ok()); - let full_path = find_full_path_result.unwrap(); - assert!(full_path.ends_with("/v2/content/sdv/vehicle.json")); - } -} diff --git a/in-vehicle-digital-twin/Cargo.toml b/core/in-vehicle-digital-twin/Cargo.toml similarity index 81% rename from in-vehicle-digital-twin/Cargo.toml rename to core/in-vehicle-digital-twin/Cargo.toml index 514079f2..8624f889 100644 --- a/in-vehicle-digital-twin/Cargo.toml +++ b/core/in-vehicle-digital-twin/Cargo.toml @@ -11,15 +11,12 @@ license = "MIT" [dependencies] async-std = { workspace = true, features = ["attributes"] } env_logger= { workspace = true } -ibeji-common = { path = "../common" } -ibeji-common_test = { path = "../common-test" } -dtdl-parser = { path = "../dtdl-parser" } iref = { workspace = true } json-ld = { git = "https://github.com/blast-hardcheese/json-ld", branch = "resolve-issue-40" } log = { workspace = true } parking_lot = { workspace = true } prost = { workspace = true } -proto = { path = "../proto" } +core-protobuf-data-access = { path = "../protobuf_data_access" } serde_json = { workspace = true } tokio = { workspace = true , features = ["macros", "rt-multi-thread"] } tonic = { workspace = true } diff --git a/in-vehicle-digital-twin/src/digitaltwin_impl.rs b/core/in-vehicle-digital-twin/src/digitaltwin_impl.rs similarity index 96% rename from in-vehicle-digital-twin/src/digitaltwin_impl.rs rename to core/in-vehicle-digital-twin/src/digitaltwin_impl.rs index 9b20f5fc..69a9cc61 100644 --- a/in-vehicle-digital-twin/src/digitaltwin_impl.rs +++ b/core/in-vehicle-digital-twin/src/digitaltwin_impl.rs @@ -4,12 +4,12 @@ extern crate iref; -use log::{debug, info}; -use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard}; -use proto::digital_twin::digital_twin_server::DigitalTwin; -use proto::digital_twin::{ +use core_protobuf_data_access::digital_twin::v1::digital_twin_server::DigitalTwin; +use core_protobuf_data_access::digital_twin::v1::{ EntityAccessInfo, FindByIdRequest, FindByIdResponse, RegisterRequest, RegisterResponse, }; +use log::{debug, info}; +use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard}; use std::collections::HashMap; use std::sync::Arc; use tonic::{Request, Response, Status}; @@ -108,13 +108,10 @@ impl DigitalTwinImpl { #[cfg(test)] mod digitaltwin_impl_tests { use super::*; - use ibeji_common_test::set_dtdl_path; - use proto::digital_twin::EndpointInfo; + use core_protobuf_data_access::digital_twin::v1::EndpointInfo; #[tokio::test] async fn find_by_id_test() { - set_dtdl_path(); - let operations = vec![String::from("Subscribe"), String::from("Unsubscribe")]; let endpoint_info = EndpointInfo { @@ -168,8 +165,6 @@ mod digitaltwin_impl_tests { #[tokio::test] async fn register_test() { - set_dtdl_path(); - let endpoint_info = EndpointInfo { protocol: String::from("grpc"), uri: String::from("http://[::1]:40010"), // Devskim: ignore DS137138 diff --git a/in-vehicle-digital-twin/src/main.rs b/core/in-vehicle-digital-twin/src/main.rs similarity index 92% rename from in-vehicle-digital-twin/src/main.rs rename to core/in-vehicle-digital-twin/src/main.rs index 3b6a6be8..7385f71a 100644 --- a/in-vehicle-digital-twin/src/main.rs +++ b/core/in-vehicle-digital-twin/src/main.rs @@ -2,10 +2,10 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT +use core_protobuf_data_access::digital_twin::v1::digital_twin_server::DigitalTwinServer; use env_logger::{Builder, Target}; use log::{debug, info, LevelFilter}; use parking_lot::RwLock; -use proto::digital_twin::digital_twin_server::DigitalTwinServer; use std::collections::HashMap; use std::net::SocketAddr; use std::sync::Arc; diff --git a/proto/Cargo.toml b/core/protobuf_data_access/Cargo.toml similarity index 92% rename from proto/Cargo.toml rename to core/protobuf_data_access/Cargo.toml index 418ea7a2..2680dfcb 100644 --- a/proto/Cargo.toml +++ b/core/protobuf_data_access/Cargo.toml @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT [package] -name = "proto" +name = "core-protobuf-data-access" version = "0.1.0" edition = "2021" license = "MIT" diff --git a/proto/build.rs b/core/protobuf_data_access/build.rs similarity index 72% rename from proto/build.rs rename to core/protobuf_data_access/build.rs index 8f95dd99..5629ce30 100644 --- a/proto/build.rs +++ b/core/protobuf_data_access/build.rs @@ -6,7 +6,10 @@ fn main() -> Result<(), Box> { tonic_build::configure() .message_attribute("EndpointInfo", "#[derive(serde::Deserialize, serde::Serialize)]") .message_attribute("EntityAccessInfo", "#[derive(serde::Deserialize, serde::Serialize)]") - .compile(&["digital_twin/v1/digital_twin.proto"], &["digital_twin/v1/"])?; + .compile( + &["../../interfaces/digital_twin/v1/digital_twin.proto"], + &["../../interfaces/digital_twin/v1/"], + )?; Ok(()) } diff --git a/proto/src/lib.rs b/core/protobuf_data_access/src/lib.rs similarity index 58% rename from proto/src/lib.rs rename to core/protobuf_data_access/src/lib.rs index 07e147e6..d8ea014d 100644 --- a/proto/src/lib.rs +++ b/core/protobuf_data_access/src/lib.rs @@ -3,6 +3,7 @@ // SPDX-License-Identifier: MIT pub mod digital_twin { - #![allow(clippy::derive_partial_eq_without_eq)] - tonic::include_proto!("digital_twin"); + pub mod v1 { + tonic::include_proto!("digital_twin"); + } } diff --git a/dtdl-parser/Cargo.toml b/dtdl-parser/Cargo.toml index de6a4722..1347b654 100644 --- a/dtdl-parser/Cargo.toml +++ b/dtdl-parser/Cargo.toml @@ -10,8 +10,6 @@ license = "MIT" [dependencies] async-std = { workspace = true, features = ["attributes"] } -ibeji-common = { path = "../common" } -ibeji-common_test = { path = "../common-test" } futures = { workspace = true } generic-json = { workspace = true, features = ["serde_json-impl"] } iref = { workspace = true } diff --git a/dtdl/samples/building.json b/dtdl-parser/dtdl/samples/building.json similarity index 100% rename from dtdl/samples/building.json rename to dtdl-parser/dtdl/samples/building.json diff --git a/dtdl/samples/demo_resources.json b/dtdl-parser/dtdl/samples/demo_resources.json similarity index 100% rename from dtdl/samples/demo_resources.json rename to dtdl-parser/dtdl/samples/demo_resources.json diff --git a/dtdl/samples/phone.json b/dtdl-parser/dtdl/samples/phone.json similarity index 100% rename from dtdl/samples/phone.json rename to dtdl-parser/dtdl/samples/phone.json diff --git a/dtdl/samples/thermostat.json b/dtdl-parser/dtdl/samples/thermostat.json similarity index 100% rename from dtdl/samples/thermostat.json rename to dtdl-parser/dtdl/samples/thermostat.json diff --git a/dtdl-parser/src/model_parser.rs b/dtdl-parser/src/model_parser.rs index d0541a48..bb5da5d2 100644 --- a/dtdl-parser/src/model_parser.rs +++ b/dtdl-parser/src/model_parser.rs @@ -3,11 +3,11 @@ // SPDX-License-Identifier: MIT use futures::executor::block_on; -use ibeji_common::find_full_path; use json_ld::{context, Document, NoLoader, Node, Object}; use log::warn; use serde_json::{Map, Value}; use std::collections::HashMap; +use std::env; use std::fs; use std::path::Path; use std::str::FromStr; @@ -48,6 +48,9 @@ impl Default for ModelParser { } impl ModelParser { + /// The DTDL-path environment variable name. + pub const DTDL_PATH: &str = "DTDL_PATH"; + /// Returns a new ModelParser instance. pub fn new() -> Self { Self {} @@ -250,7 +253,7 @@ impl ModelParser { /// {"title": "http://purl.org/dc/terms/title"} /// ] fn preprocess(&mut self, doc: &mut Value) -> Result<(), String> { - let dtdl_2_context_path_string = find_full_path("v2/context/DTDL.v2.context.json")?; + let dtdl_2_context_path_string = Self::find_full_path("v2/context/DTDL.v2.context.json")?; let dtdl_2_context_path_string_unwrapped = dtdl_2_context_path_string; let dtdl_2_context_path = Path::new(&dtdl_2_context_path_string_unwrapped); let dtdl_2_context_value = self.retrieve_context(dtdl_2_context_path)?; @@ -1031,22 +1034,88 @@ impl ModelParser { Ok(()) } + + /// Find the full path given a relative path and a preset DTDL_PATH environment variable (containing a semicolon-separated list of DTDL directories). + /// + /// # Arguments + /// `relative_path` - The relative path. + pub fn find_full_path(relative_path: &str) -> Result { + match env::var(Self::DTDL_PATH) { + Ok(paths) => { + let split = paths.split(';'); + let vec: Vec<&str> = split.collect(); + for path in vec { + let full_path = Path::new(path).join(relative_path); + if full_path.exists() { + return Ok(full_path.to_str().unwrap().to_string()); + } + } + } + Err(_) => { + return Err(String::from( + "Unable to get the environment variable DTDL_PATH. Please set it.", + )) + } + } + Err(String::from("Unable to resolve the full path")) + } } #[cfg(test)] mod model_parser_tests { use super::*; - use ibeji_common_test::set_dtdl_path; + use log::trace; use std::fs; use std::path::Path; use std::vec::Vec; + /// The DTDL-path environment variable name. + const CARGO_MANIFEST_DIR: &str = "CARGO_MANIFEST_DIR"; + + /// Retrieve the contents of the DTDL from the specified file path. + /// + /// # Arguments: + /// `file_path` - The file path where the DTDL is located. fn retrieve_dtdl(file_path: &str) -> Result { let path = Path::new(file_path); let read_result = fs::read_to_string(path); match read_result { Ok(contents) => Ok(contents), - Err(error) => Err(format!("Unable to retrieve the DTDL due to: {error:?}")), + Err(error) => Err(format!("Unable to retrieve the DTDL due to: {error}")), + } + } + + /// Get the repository's directory. + fn get_repo_dir() -> Option { + // CARGO_MANIFEST_DIR - The directory containing the manifest of your package. + let cargo_manifest_dir_result = env::var(CARGO_MANIFEST_DIR); + if let Ok(cargo_manifest_dir) = cargo_manifest_dir_result { + let cargo_manifest_dir_path = Path::new(&cargo_manifest_dir); + let parent_result = cargo_manifest_dir_path.parent(); + if let Some(parent) = parent_result { + parent.to_str().map(String::from) + } else { + None + } + } else { + None + } + } + + /// Set the DTDL_PATH environment, so that the tests can use it. + fn set_dtdl_path() { + let repo_dir_result = get_repo_dir(); + if let Some(repo_dir) = repo_dir_result { + let value = format!( + "{repo_dir}/external/opendigitaltwins-dtdl/DTDL;{repo_dir}/external/iot-plugandplay-models;{repo_dir}/dtdl-parser/dtdl;{repo_dir}/digital-twin-model/dtdl" + ); + env::set_var(ModelParser::DTDL_PATH, &value); + trace!("{}={value}", ModelParser::DTDL_PATH); + } else { + warn!( + "Unable to set {}, as repo directory could not be determined.", + ModelParser::DTDL_PATH + ); } } @@ -1057,21 +1126,21 @@ mod model_parser_tests { let mut json_texts = Vec::::new(); let device_information_full_path_result = - find_full_path("dtmi/azure/devicemanagement/deviceinformation-1.json"); + ModelParser::find_full_path("dtmi/azure/devicemanagement/deviceinformation-1.json"); assert!(device_information_full_path_result.is_ok()); let device_information_contents_result = retrieve_dtdl(&device_information_full_path_result.unwrap()); assert!(device_information_contents_result.is_ok()); json_texts.push(device_information_contents_result.unwrap()); - let thermostat_full_path_result = find_full_path("v2/samples/Thermostat.json"); + let thermostat_full_path_result = ModelParser::find_full_path("v2/samples/Thermostat.json"); assert!(thermostat_full_path_result.is_ok()); let thermostat_contents_result = retrieve_dtdl(&thermostat_full_path_result.unwrap()); assert!(thermostat_contents_result.is_ok()); json_texts.push(thermostat_contents_result.unwrap()); let temp_controller_full_path_result = - find_full_path("v2/samples/TemperatureController.json"); + ModelParser::find_full_path("v2/samples/TemperatureController.json"); assert!(temp_controller_full_path_result.is_ok()); let temp_controller_contents_result = retrieve_dtdl(&temp_controller_full_path_result.unwrap()); @@ -1101,7 +1170,7 @@ mod model_parser_tests { let mut json_texts = Vec::::new(); - let vehicle_path_result = find_full_path("v2/content/sdv/vehicle.json"); + let vehicle_path_result = ModelParser::find_full_path("v2/content/sdv/vehicle.json"); assert!(vehicle_path_result.is_ok()); let vehicle_contents_result = retrieve_dtdl(&vehicle_path_result.unwrap()); assert!(vehicle_contents_result.is_ok()); @@ -1137,4 +1206,14 @@ mod model_parser_tests { let show_notification_entity_result = model_dict.get(&show_notification_id.unwrap()); assert!(show_notification_entity_result.is_some()); } + + #[test] + fn find_full_path_test() { + set_dtdl_path(); + + let find_full_path_result = ModelParser::find_full_path("v2/content/sdv/vehicle.json"); + assert!(find_full_path_result.is_ok()); + let full_path = find_full_path_result.unwrap(); + assert!(full_path.ends_with("/v2/content/sdv/vehicle.json")); + } } diff --git a/external/iot-plugandplay-models b/external/iot-plugandplay-models new file mode 160000 index 00000000..8d9ea407 --- /dev/null +++ b/external/iot-plugandplay-models @@ -0,0 +1 @@ +Subproject commit 8d9ea407dec9dce595073395dfa8118ec6b0f85f diff --git a/opendigitaltwins-dtdl b/external/opendigitaltwins-dtdl similarity index 100% rename from opendigitaltwins-dtdl rename to external/opendigitaltwins-dtdl diff --git a/proto/digital_twin/v1/digital_twin.proto b/interfaces/digital_twin/v1/digital_twin.proto similarity index 100% rename from proto/digital_twin/v1/digital_twin.proto rename to interfaces/digital_twin/v1/digital_twin.proto diff --git a/iot-plugandplay-models b/iot-plugandplay-models deleted file mode 160000 index 4595d570..00000000 --- a/iot-plugandplay-models +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4595d570a964b1e634dbead8e437fe1c004f613b diff --git a/samples/command/consumer/Cargo.toml b/samples/command/Cargo.toml similarity index 61% rename from samples/command/consumer/Cargo.toml rename to samples/command/Cargo.toml index a9d4706d..f69c90f2 100644 --- a/samples/command/consumer/Cargo.toml +++ b/samples/command/Cargo.toml @@ -3,25 +3,32 @@ # SPDX-License-Identifier: MIT [package] -name = "command-consumer" +name = "samples-command" version = "0.1.0" edition = "2021" license = "MIT" [dependencies] async-std = { workspace = true, features = ["attributes"] } -digital-twin-model = { path = "../../../digital-twin-model" } +digital-twin-model = { path = "../../digital-twin-model" } env_logger= { workspace = true } -iref = { workspace = true } -json-ld = { git = "https://github.com/blast-hardcheese/json-ld", branch = "resolve-issue-40" } log = { workspace = true } +parking_lot = { workspace = true } prost = { workspace = true } -samples_common = { path = "../../common" } -samples_proto = { path = "../../proto" } +samples-common = { path = "../common" } +samples-protobuf-data-access = { path = "../protobuf_data_access" } serde_json = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } tonic = { workspace = true } uuid = { workspace = true, features = ["v4", "fast-rng", "macro-diagnostics"] } [build-dependencies] -tonic-build = { workspace = true } \ No newline at end of file +tonic-build = { workspace = true } + +[[bin]] +name = "command-provider" +path = "provider/src/main.rs" + +[[bin]] +name = "command-consumer" +path = "consumer/src/main.rs" \ No newline at end of file diff --git a/samples/command/consumer/src/consumer_impl.rs b/samples/command/consumer/src/consumer_impl.rs index 2577fbb8..361efc63 100644 --- a/samples/command/consumer/src/consumer_impl.rs +++ b/samples/command/consumer/src/consumer_impl.rs @@ -3,8 +3,8 @@ // SPDX-License-Identifier: MIT use log::{info, warn}; -use samples_proto::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_server::DigitalTwinConsumer; -use samples_proto::sample_grpc::v1::digital_twin_consumer::{ +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_server::DigitalTwinConsumer; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_consumer::{ PublishRequest, PublishResponse, RespondRequest, RespondResponse, }; use tonic::{Request, Response, Status}; diff --git a/samples/command/consumer/src/main.rs b/samples/command/consumer/src/main.rs index e053c118..e6351857 100644 --- a/samples/command/consumer/src/main.rs +++ b/samples/command/consumer/src/main.rs @@ -8,9 +8,9 @@ use digital_twin_model::sdv_v1 as sdv; use env_logger::{Builder, Target}; use log::{debug, info, warn, LevelFilter}; use samples_common::{digital_twin_operation, digital_twin_protocol, find_provider_endpoint}; -use samples_proto::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_server::DigitalTwinConsumerServer; -use samples_proto::sample_grpc::v1::digital_twin_provider::digital_twin_provider_client::DigitalTwinProviderClient; -use samples_proto::sample_grpc::v1::digital_twin_provider::InvokeRequest; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_server::DigitalTwinConsumerServer; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_provider::digital_twin_provider_client::DigitalTwinProviderClient; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_provider::InvokeRequest; use std::net::SocketAddr; use tokio::time::{sleep, Duration}; use tonic::transport::Server; diff --git a/samples/command/provider/Cargo.toml b/samples/command/provider/Cargo.toml deleted file mode 100644 index 61eb2773..00000000 --- a/samples/command/provider/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT license. -# SPDX-License-Identifier: MIT - -[package] -name = "command-provider" -version = "0.1.0" -edition = "2021" -license = "MIT" - -[dependencies] -async-std = { workspace = true, features = ["attributes"] } -digital-twin-model = { path = "../../../digital-twin-model" } -env_logger= { workspace = true } -ibeji-common = { path = "../../../common" } -json-ld = { git = "https://github.com/blast-hardcheese/json-ld", branch = "resolve-issue-40" } -log = { workspace = true} -parking_lot = { workspace = true } -prost = { workspace = true } -proto = { path = "../../../proto" } -samples_common = { path = "../../common" } -samples_proto = { path = "../../proto" } -serde_json = { workspace = true } -tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } -tonic = { workspace = true } -uuid = { workspace = true, features = ["v4", "fast-rng", "macro-diagnostics"] } - -[build-dependencies] -tonic-build = { workspace = true } \ No newline at end of file diff --git a/samples/command/provider/src/main.rs b/samples/command/provider/src/main.rs index 0b1c49fd..4ad01769 100644 --- a/samples/command/provider/src/main.rs +++ b/samples/command/provider/src/main.rs @@ -8,10 +8,10 @@ use digital_twin_model::sdv_v1 as sdv; use env_logger::{Builder, Target}; use log::{debug, info, LevelFilter}; use parking_lot::Mutex; -use proto::digital_twin::digital_twin_client::DigitalTwinClient; -use proto::digital_twin::{EndpointInfo, EntityAccessInfo, RegisterRequest}; use samples_common::{digital_twin_operation, digital_twin_protocol}; -use samples_proto::sample_grpc::v1::digital_twin_provider::digital_twin_provider_server::DigitalTwinProviderServer; +use samples_protobuf_data_access::digital_twin::v1::digital_twin_client::DigitalTwinClient; +use samples_protobuf_data_access::digital_twin::v1::{EndpointInfo, EntityAccessInfo, RegisterRequest}; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_provider::digital_twin_provider_server::DigitalTwinProviderServer; use std::net::SocketAddr; use std::sync::Arc; use tonic::transport::Server; diff --git a/samples/command/provider/src/provider_impl.rs b/samples/command/provider/src/provider_impl.rs index 6ded9258..57b5061f 100644 --- a/samples/command/provider/src/provider_impl.rs +++ b/samples/command/provider/src/provider_impl.rs @@ -4,10 +4,10 @@ use log::{info, warn}; use parking_lot::Mutex; -use samples_proto::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_client::DigitalTwinConsumerClient; -use samples_proto::sample_grpc::v1::digital_twin_consumer::RespondRequest; -use samples_proto::sample_grpc::v1::digital_twin_provider::digital_twin_provider_server::DigitalTwinProvider; -use samples_proto::sample_grpc::v1::digital_twin_provider::{ +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_client::DigitalTwinConsumerClient; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_consumer::RespondRequest; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_provider::digital_twin_provider_server::DigitalTwinProvider; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_provider::{ GetRequest, GetResponse, InvokeRequest, InvokeResponse, SetRequest, SetResponse, SubscribeRequest, SubscribeResponse, UnsubscribeRequest, UnsubscribeResponse, }; diff --git a/samples/common/Cargo.toml b/samples/common/Cargo.toml index 9f3ee0df..e5d33cb7 100644 --- a/samples/common/Cargo.toml +++ b/samples/common/Cargo.toml @@ -3,12 +3,12 @@ # SPDX-License-Identifier: MIT [package] -name = "samples_common" +name = "samples-common" version = "0.1.0" edition = "2021" license = "MIT" [dependencies] log = { workspace = true } -proto = { path = "../../proto" } +samples-protobuf-data-access = { path = "../protobuf_data_access" } tonic = { workspace = true } \ No newline at end of file diff --git a/samples/common/src/lib.rs b/samples/common/src/lib.rs index 6c44676d..84421d40 100644 --- a/samples/common/src/lib.rs +++ b/samples/common/src/lib.rs @@ -3,8 +3,8 @@ // SPDX-License-Identifier: MIT use log::{debug, info}; -use proto::digital_twin::digital_twin_client::DigitalTwinClient; -use proto::digital_twin::{EndpointInfo, FindByIdRequest}; +use samples_protobuf_data_access::digital_twin::v1::digital_twin_client::DigitalTwinClient; +use samples_protobuf_data_access::digital_twin::v1::{EndpointInfo, FindByIdRequest}; /// Supported digital twin operations. pub mod digital_twin_operation { diff --git a/samples/proto/sample_grpc/v1/digital_twin_consumer.proto b/samples/interfaces/sample_grpc/v1/digital_twin_consumer.proto similarity index 100% rename from samples/proto/sample_grpc/v1/digital_twin_consumer.proto rename to samples/interfaces/sample_grpc/v1/digital_twin_consumer.proto diff --git a/samples/proto/sample_grpc/v1/digital_twin_provider.proto b/samples/interfaces/sample_grpc/v1/digital_twin_provider.proto similarity index 100% rename from samples/proto/sample_grpc/v1/digital_twin_provider.proto rename to samples/interfaces/sample_grpc/v1/digital_twin_provider.proto diff --git a/samples/mixed/consumer/Cargo.toml b/samples/mixed/Cargo.toml similarity index 62% rename from samples/mixed/consumer/Cargo.toml rename to samples/mixed/Cargo.toml index 783834ea..006f68da 100644 --- a/samples/mixed/consumer/Cargo.toml +++ b/samples/mixed/Cargo.toml @@ -3,26 +3,32 @@ # SPDX-License-Identifier: MIT [package] -name = "mixed-consumer" +name = "samples-mixed" version = "0.1.0" edition = "2021" license = "MIT" [dependencies] async-std = { workspace = true, features = ["attributes"] } -digital-twin-model = { path = "../../../digital-twin-model" } +digital-twin-model = { path = "../../digital-twin-model" } env_logger= { workspace = true } -iref = { workspace = true } -json-ld = { git = "https://github.com/blast-hardcheese/json-ld", branch = "resolve-issue-40" } log = { workspace = true } +parking_lot = { workspace = true } prost = { workspace = true } -# proto = { path = "../../../proto" } -samples_common = { path = "../../common" } -samples_proto = { path = "../../proto" } +samples-common = { path = "../common" } +samples-protobuf-data-access = { path = "../protobuf_data_access" } serde_json = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } tonic = { workspace = true } uuid = { workspace = true, features = ["v4", "fast-rng", "macro-diagnostics"] } [build-dependencies] -tonic-build = { workspace = true } \ No newline at end of file +tonic-build = { workspace = true } + +[[bin]] +name = "mixed-provider" +path = "provider/src/main.rs" + +[[bin]] +name = "mixed-consumer" +path = "consumer/src/main.rs" \ No newline at end of file diff --git a/samples/mixed/consumer/src/consumer_impl.rs b/samples/mixed/consumer/src/consumer_impl.rs index 2a8b457f..736adb30 100644 --- a/samples/mixed/consumer/src/consumer_impl.rs +++ b/samples/mixed/consumer/src/consumer_impl.rs @@ -3,8 +3,8 @@ // SPDX-License-Identifier: MIT use log::info; -use samples_proto::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_server::DigitalTwinConsumer; -use samples_proto::sample_grpc::v1::digital_twin_consumer::{ +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_server::DigitalTwinConsumer; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_consumer::{ PublishRequest, PublishResponse, RespondRequest, RespondResponse, }; use tonic::{Request, Response, Status}; diff --git a/samples/mixed/consumer/src/main.rs b/samples/mixed/consumer/src/main.rs index f7e06c29..cefc42d3 100644 --- a/samples/mixed/consumer/src/main.rs +++ b/samples/mixed/consumer/src/main.rs @@ -8,9 +8,9 @@ use digital_twin_model::sdv_v1 as sdv; use env_logger::{Builder, Target}; use log::{debug, info, warn, LevelFilter}; use samples_common::{digital_twin_operation, digital_twin_protocol, find_provider_endpoint}; -use samples_proto::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_server::DigitalTwinConsumerServer; -use samples_proto::sample_grpc::v1::digital_twin_provider::digital_twin_provider_client::DigitalTwinProviderClient; -use samples_proto::sample_grpc::v1::digital_twin_provider::{ +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_server::DigitalTwinConsumerServer; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_provider::digital_twin_provider_client::DigitalTwinProviderClient; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_provider::{ InvokeRequest, SetRequest, SubscribeRequest, }; use std::net::SocketAddr; diff --git a/samples/mixed/provider/Cargo.toml b/samples/mixed/provider/Cargo.toml deleted file mode 100644 index 7a65409e..00000000 --- a/samples/mixed/provider/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT license. -# SPDX-License-Identifier: MIT - -[package] -name = "mixed-provider" -version = "0.1.0" -edition = "2021" -license = "MIT" - -[dependencies] -async-std = { workspace = true, features = ["attributes"] } -digital-twin-model = { path = "../../../digital-twin-model" } -env_logger= { workspace = true } -ibeji-common = { path = "../../../common" } -json-ld = { git = "https://github.com/blast-hardcheese/json-ld", branch = "resolve-issue-40" } -log = { workspace = true } -parking_lot = { workspace = true } -prost = { workspace = true } -proto = { path = "../../../proto" } -samples_common = { path = "../../common" } -samples_proto = { path = "../../proto" } -serde_json = { workspace = true } -tokio = { workspace = true , features = ["macros", "rt-multi-thread"] } -tonic = { workspace = true } -uuid = { workspace = true, features = ["v4", "fast-rng", "macro-diagnostics"] } - -[build-dependencies] -tonic-build = { workspace = true } \ No newline at end of file diff --git a/samples/mixed/provider/src/main.rs b/samples/mixed/provider/src/main.rs index 8d473195..2dbe29a2 100644 --- a/samples/mixed/provider/src/main.rs +++ b/samples/mixed/provider/src/main.rs @@ -9,12 +9,12 @@ use digital_twin_model::sdv_v1 as sdv; use env_logger::{Builder, Target}; use log::{debug, info, warn, LevelFilter}; use parking_lot::{Mutex, MutexGuard}; -use proto::digital_twin::digital_twin_client::DigitalTwinClient; -use proto::digital_twin::{EndpointInfo, EntityAccessInfo, RegisterRequest}; use samples_common::{digital_twin_operation, digital_twin_protocol}; -use samples_proto::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_client::DigitalTwinConsumerClient; -use samples_proto::sample_grpc::v1::digital_twin_consumer::PublishRequest; -use samples_proto::sample_grpc::v1::digital_twin_provider::digital_twin_provider_server::DigitalTwinProviderServer; +use samples_protobuf_data_access::digital_twin::v1::digital_twin_client::DigitalTwinClient; +use samples_protobuf_data_access::digital_twin::v1::{EndpointInfo, EntityAccessInfo, RegisterRequest}; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_client::DigitalTwinConsumerClient; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_consumer::PublishRequest; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_provider::digital_twin_provider_server::DigitalTwinProviderServer; use std::collections::HashSet; use std::net::SocketAddr; use std::sync::Arc; diff --git a/samples/mixed/provider/src/provider_impl.rs b/samples/mixed/provider/src/provider_impl.rs index 79e9d830..2df58737 100644 --- a/samples/mixed/provider/src/provider_impl.rs +++ b/samples/mixed/provider/src/provider_impl.rs @@ -5,10 +5,10 @@ use digital_twin_model::sdv_v1 as sdv; use log::{debug, info, warn}; use parking_lot::{Mutex, MutexGuard}; -use samples_proto::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_client::DigitalTwinConsumerClient; -use samples_proto::sample_grpc::v1::digital_twin_consumer::RespondRequest; -use samples_proto::sample_grpc::v1::digital_twin_provider::digital_twin_provider_server::DigitalTwinProvider; -use samples_proto::sample_grpc::v1::digital_twin_provider::{ +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_client::DigitalTwinConsumerClient; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_consumer::RespondRequest; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_provider::digital_twin_provider_server::DigitalTwinProvider; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_provider::{ GetRequest, GetResponse, InvokeRequest, InvokeResponse, SetRequest, SetResponse, SubscribeRequest, SubscribeResponse, UnsubscribeRequest, UnsubscribeResponse, }; diff --git a/samples/property/consumer/Cargo.toml b/samples/property/Cargo.toml similarity index 65% rename from samples/property/consumer/Cargo.toml rename to samples/property/Cargo.toml index 6faf3e54..ea21637e 100644 --- a/samples/property/consumer/Cargo.toml +++ b/samples/property/Cargo.toml @@ -3,22 +3,20 @@ # SPDX-License-Identifier: MIT [package] -name = "property-consumer" +name = "samples-property" version = "0.1.0" edition = "2021" license = "MIT" [dependencies] async-std = { workspace = true, features = ["attributes"] } -digital-twin-model = { path = "../../../digital-twin-model" } +digital-twin-model = { path = "../../digital-twin-model" } env_logger= { workspace = true } -iref = { workspace = true } -json-ld = { git = "https://github.com/blast-hardcheese/json-ld", branch = "resolve-issue-40" } log = { workspace = true } +parking_lot = { workspace = true } prost = { workspace = true } -proto = { path = "../../../proto" } -samples_common = { path = "../../common" } -samples_proto = { path = "../../proto" } +samples-common = { path = "../common" } +samples-protobuf-data-access = { path = "../protobuf_data_access" } serde_json = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } tonic = { workspace = true } @@ -26,3 +24,11 @@ uuid = { workspace = true, features = ["v4", "fast-rng", "macro-diagnostics"] } [build-dependencies] tonic-build = { workspace = true } + +[[bin]] +name = "property-provider" +path = "provider/src/main.rs" + +[[bin]] +name = "property-consumer" +path = "consumer/src/main.rs" \ No newline at end of file diff --git a/samples/property/consumer/src/consumer_impl.rs b/samples/property/consumer/src/consumer_impl.rs index c06f31f7..284b4060 100644 --- a/samples/property/consumer/src/consumer_impl.rs +++ b/samples/property/consumer/src/consumer_impl.rs @@ -3,8 +3,8 @@ // SPDX-License-Identifier: MIT use log::{info, warn}; -use samples_proto::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_server::DigitalTwinConsumer; -use samples_proto::sample_grpc::v1::digital_twin_consumer::{ +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_server::DigitalTwinConsumer; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_consumer::{ PublishRequest, PublishResponse, RespondRequest, RespondResponse, }; use tonic::{Request, Response, Status}; diff --git a/samples/property/consumer/src/main.rs b/samples/property/consumer/src/main.rs index bc425a5b..781a2285 100644 --- a/samples/property/consumer/src/main.rs +++ b/samples/property/consumer/src/main.rs @@ -6,9 +6,9 @@ use digital_twin_model::sdv_v1 as sdv; use env_logger::{Builder, Target}; use log::{debug, info, LevelFilter}; use samples_common::{digital_twin_operation, digital_twin_protocol, find_provider_endpoint}; -use samples_proto::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_server::DigitalTwinConsumerServer; -use samples_proto::sample_grpc::v1::digital_twin_provider::digital_twin_provider_client::DigitalTwinProviderClient; -use samples_proto::sample_grpc::v1::digital_twin_provider::SubscribeRequest; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_server::DigitalTwinConsumerServer; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_provider::digital_twin_provider_client::DigitalTwinProviderClient; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_provider::SubscribeRequest; use std::net::SocketAddr; use tonic::transport::Server; diff --git a/samples/property/provider/Cargo.toml b/samples/property/provider/Cargo.toml deleted file mode 100644 index 77568949..00000000 --- a/samples/property/provider/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT license. -# SPDX-License-Identifier: MIT - -[package] -name = "property-provider" -version = "0.1.0" -edition = "2021" -license = "MIT" - -[dependencies] -async-std = { workspace = true, features = ["attributes"] } -digital-twin-model = { path = "../../../digital-twin-model" } -env_logger= { workspace = true } -ibeji-common = { path = "../../../common" } -json-ld = { git = "https://github.com/blast-hardcheese/json-ld", branch = "resolve-issue-40" } -log = { workspace = true} -parking_lot = { workspace = true } -prost = { workspace = true } -proto = { path = "../../../proto" } -samples_common = { path = "../../common" } -samples_proto = { path = "../../proto" } -serde_json = { workspace = true } -tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } -tonic = { workspace = true } - -[build-dependencies] -tonic-build = { workspace = true } \ No newline at end of file diff --git a/samples/property/provider/src/main.rs b/samples/property/provider/src/main.rs index c26a1ec8..7e00373c 100644 --- a/samples/property/provider/src/main.rs +++ b/samples/property/provider/src/main.rs @@ -8,12 +8,12 @@ use digital_twin_model::sdv_v1 as sdv; use env_logger::{Builder, Target}; use log::{debug, info, warn, LevelFilter}; use parking_lot::{Mutex, MutexGuard}; -use proto::digital_twin::digital_twin_client::DigitalTwinClient; -use proto::digital_twin::{EndpointInfo, EntityAccessInfo, RegisterRequest}; use samples_common::{digital_twin_operation, digital_twin_protocol}; -use samples_proto::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_client::DigitalTwinConsumerClient; -use samples_proto::sample_grpc::v1::digital_twin_consumer::PublishRequest; -use samples_proto::sample_grpc::v1::digital_twin_provider::digital_twin_provider_server::DigitalTwinProviderServer; +use samples_protobuf_data_access::digital_twin::v1::digital_twin_client::DigitalTwinClient; +use samples_protobuf_data_access::digital_twin::v1::{EndpointInfo, EntityAccessInfo, RegisterRequest}; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_consumer::digital_twin_consumer_client::DigitalTwinConsumerClient; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_consumer::PublishRequest; +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_provider::digital_twin_provider_server::DigitalTwinProviderServer; use std::collections::HashSet; use std::net::SocketAddr; use std::sync::Arc; diff --git a/samples/property/provider/src/provider_impl.rs b/samples/property/provider/src/provider_impl.rs index 7c889a9e..be9ab5f5 100644 --- a/samples/property/provider/src/provider_impl.rs +++ b/samples/property/provider/src/provider_impl.rs @@ -4,7 +4,7 @@ use log::{debug, info, warn}; use parking_lot::{Mutex, MutexGuard}; -use samples_proto::sample_grpc::v1::digital_twin_provider::{ +use samples_protobuf_data_access::sample_grpc::v1::digital_twin_provider::{ digital_twin_provider_server::DigitalTwinProvider, GetRequest, GetResponse, InvokeRequest, InvokeResponse, SetRequest, SetResponse, SubscribeRequest, SubscribeResponse, UnsubscribeRequest, UnsubscribeResponse, diff --git a/samples/proto/build.rs b/samples/proto/build.rs deleted file mode 100644 index da6e3d0b..00000000 --- a/samples/proto/build.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. -// SPDX-License-Identifier: MIT - -fn main() -> Result<(), Box> { - tonic_build::compile_protos("sample_grpc/v1/digital_twin_consumer.proto")?; - tonic_build::compile_protos("sample_grpc/v1/digital_twin_provider.proto")?; - Ok(()) -} diff --git a/samples/proto/Cargo.toml b/samples/protobuf_data_access/Cargo.toml similarity index 80% rename from samples/proto/Cargo.toml rename to samples/protobuf_data_access/Cargo.toml index b5e9cc25..cb0f0f82 100644 --- a/samples/proto/Cargo.toml +++ b/samples/protobuf_data_access/Cargo.toml @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT [package] -name = "samples_proto" +name = "samples-protobuf-data-access" version = "1.0.0" edition = "2021" license = "MIT" @@ -11,6 +11,7 @@ license = "MIT" [dependencies] tonic = { workspace = true } prost = { workspace = true } +serde = { workspace = true, features = ["derive"] } tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } [build-dependencies] diff --git a/samples/protobuf_data_access/build.rs b/samples/protobuf_data_access/build.rs new file mode 100644 index 00000000..6b3aeb15 --- /dev/null +++ b/samples/protobuf_data_access/build.rs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +// SPDX-License-Identifier: MIT + +fn main() -> Result<(), Box> { + tonic_build::compile_protos("../interfaces/sample_grpc/v1/digital_twin_consumer.proto")?; + tonic_build::compile_protos("../interfaces/sample_grpc/v1/digital_twin_provider.proto")?; + tonic_build::configure() + .message_attribute("EndpointInfo", "#[derive(serde::Deserialize, serde::Serialize)]") + .message_attribute("EntityAccessInfo", "#[derive(serde::Deserialize, serde::Serialize)]") + .compile( + &["../../interfaces/digital_twin/v1/digital_twin.proto"], + &["../../interfaces/digital_twin/v1/"], + )?; + + Ok(()) +} diff --git a/samples/proto/src/lib.rs b/samples/protobuf_data_access/src/lib.rs similarity index 79% rename from samples/proto/src/lib.rs rename to samples/protobuf_data_access/src/lib.rs index 2e86a309..23c61b49 100644 --- a/samples/proto/src/lib.rs +++ b/samples/protobuf_data_access/src/lib.rs @@ -2,6 +2,12 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT +pub mod digital_twin { + pub mod v1 { + tonic::include_proto!("digital_twin"); + } +} + pub mod sample_grpc { pub mod v1 { pub mod digital_twin_consumer { diff --git a/infra/build/scripts/dev-setup.sh b/tools/dev-setup.sh similarity index 100% rename from infra/build/scripts/dev-setup.sh rename to tools/dev-setup.sh