diff --git a/digital-twin-model/src/sdv_v1.rs b/digital-twin-model/src/sdv_v1.rs index 019dad7e..4cb90e16 100644 --- a/digital-twin-model/src/sdv_v1.rs +++ b/digital-twin-model/src/sdv_v1.rs @@ -161,7 +161,7 @@ pub mod basic_airbag_seat_massager { #[derivative(Default(value = "crate::sdv_v1::context()"))] pub context: Vec, #[serde(rename = "@id")] - pub instance_id: String, + pub instance_id: String, #[serde(rename = "@type")] #[derivative(Default( value = "crate::sdv_v1::basic_airbag_seat_massager::ID.to_string()" @@ -215,8 +215,7 @@ pub mod cabin { #[derive(derivative::Derivative)] #[derivative(Default)] - #[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug)] - #[derive(PartialEq)] + #[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug, PartialEq)] pub enum SEAT_POSITION_TYPE { #[derivative(Default)] /// No value @@ -394,7 +393,7 @@ pub mod premium_airbag_seat_massager { #[derivative(Default(value = "crate::sdv_v1::context()"))] pub context: Vec, #[serde(rename = "@id")] - pub instance_id: String, + pub instance_id: String, #[serde(rename = "@type")] #[derivative(Default( value = "crate::sdv_v1::premium_airbag_seat_massager::ID.to_string()" diff --git a/samples/graph/consumer/src/main.rs b/samples/graph/consumer/src/main.rs index cec096e3..3bc82aa5 100644 --- a/samples/graph/consumer/src/main.rs +++ b/samples/graph/consumer/src/main.rs @@ -24,7 +24,11 @@ async fn interact_with_digital_twin(invehicle_digital_twin_uri: String) -> Resul // Connect to the digital twin graph service. let client = Retry::spawn(retry_strategy.clone(), || async { - DigitalTwinGraphClient::connect(invehicle_digital_twin_uri.clone()).await.map_err(|err_msg| format!("Unable to connect to the digital twin graph service due to: {err_msg}")) + DigitalTwinGraphClient::connect(invehicle_digital_twin_uri.clone()).await.map_err( + |err_msg| { + format!("Unable to connect to the digital twin graph service due to: {err_msg}") + }, + ) }) .await?; @@ -35,7 +39,10 @@ async fn interact_with_digital_twin(invehicle_digital_twin_uri: String) -> Resul let request: FindRequest = FindRequest { model_id: sdv::vehicle::ID.to_string() }; - client.find(request).await.map_err(|err_msg| format!("Unable to call find due to: {err_msg}")) + client + .find(request) + .await + .map_err(|err_msg| format!("Unable to call find due to: {err_msg}")) }) .await?; let find_vehicle_response_inner = find_vehicle_response.into_inner(); @@ -45,12 +52,13 @@ async fn interact_with_digital_twin(invehicle_digital_twin_uri: String) -> Resul } // For now, we will just use the first vehicle instance. - let vehicle: sdv::vehicle::TYPE = serde_json::from_str(&find_vehicle_response_inner.values[0]).unwrap(); + let vehicle: sdv::vehicle::TYPE = + serde_json::from_str(&find_vehicle_response_inner.values[0]).unwrap(); // info!("The vehicle is: {:?}", vehicle); info!("The vehicle's instance id is: {:?}", vehicle.instance_id); if vehicle.cabin.is_empty() { return Err("The vehicle does not have a cabin".to_string()); - } + } let cabin_instance_id = vehicle.cabin[0].instance_id.clone(); info!("The cabin's instance id is: {:?}", cabin_instance_id); @@ -59,9 +67,13 @@ async fn interact_with_digital_twin(invehicle_digital_twin_uri: String) -> Resul // Make a local mutable copy for use only within this closure body. let mut client = client.clone(); - let request: GetRequest = GetRequest { instance_id: cabin_instance_id.clone(), member_path: "".to_string() }; + let request: GetRequest = + GetRequest { instance_id: cabin_instance_id.clone(), member_path: "".to_string() }; - client.get(request.clone()).await.map_err(|err_msg| format!("Unable to call get due to: {err_msg}")) + client + .get(request.clone()) + .await + .map_err(|err_msg| format!("Unable to call get due to: {err_msg}")) }) .await?; let get_cabin_response_inner = get_cabin_response.into_inner(); @@ -70,7 +82,9 @@ async fn interact_with_digital_twin(invehicle_digital_twin_uri: String) -> Resul let cabin: sdv::cabin::TYPE = serde_json::from_str(&get_cabin_response_inner.value).unwrap(); // info!("The cabin is: {:?}", cabin); for seat_relationship in cabin.seat.iter() { - if (seat_relationship.seat_row == 1) && (seat_relationship.seat_position == sdv::cabin::seat::SEAT_POSITION_TYPE::left) { + if (seat_relationship.seat_row == 1) + && (seat_relationship.seat_position == sdv::cabin::seat::SEAT_POSITION_TYPE::left) + { info!("The front left seat's instance id is: {:?}", seat_relationship.instance_id); front_left_seat_instance_id_option = Some(seat_relationship.instance_id.clone()); } @@ -87,9 +101,15 @@ async fn interact_with_digital_twin(invehicle_digital_twin_uri: String) -> Resul // Make a local mutable copy for use only within this closure body. let mut client = client.clone(); - let request: GetRequest = GetRequest { instance_id: front_left_seat_instance_id.clone(), member_path: "".to_string() }; + let request: GetRequest = GetRequest { + instance_id: front_left_seat_instance_id.clone(), + member_path: "".to_string(), + }; - client.get(request.clone()).await.map_err(|err_msg| format!("Unable to call get due to: {err_msg}")) + client + .get(request.clone()) + .await + .map_err(|err_msg| format!("Unable to call get due to: {err_msg}")) }) .await?; let get_seat_response_inner = get_seat_response.into_inner(); @@ -107,19 +127,30 @@ async fn interact_with_digital_twin(invehicle_digital_twin_uri: String) -> Resul // Make a local mutable copy for use only within this closure body. let mut client = client.clone(); - let request: GetRequest = GetRequest { instance_id: seat_massager_instance_id.clone(), member_path: "".to_string() }; + let request: GetRequest = GetRequest { + instance_id: seat_massager_instance_id.clone(), + member_path: "".to_string(), + }; - client.get(request.clone()).await.map_err(|err_msg| format!("Unable to call get due to: {err_msg}")) + client + .get(request.clone()) + .await + .map_err(|err_msg| format!("Unable to call get due to: {err_msg}")) }) .await?; let get_seat_massager_response_inner = get_seat_massager_response.into_inner(); - let seat_massager_json: serde_json::Value = serde_json::from_str(&get_seat_massager_response_inner.value).unwrap(); + let seat_massager_json: serde_json::Value = + serde_json::from_str(&get_seat_massager_response_inner.value).unwrap(); if seat_massager_json["@type"] != sdv::premium_airbag_seat_massager::ID { - return Err(format!("The seat massager instance is not of the expected model, instead it is a {0}", seat_massager_json["@type"])); + return Err(format!( + "The seat massager instance is not of the expected model, instead it is a {0}", + seat_massager_json["@type"] + )); } - let seat_massager: sdv::premium_airbag_seat_massager::TYPE = serde_json::from_value(seat_massager_json.clone()).unwrap(); + let seat_massager: sdv::premium_airbag_seat_massager::TYPE = + serde_json::from_value(seat_massager_json.clone()).unwrap(); info!("The seat massager is: {:?}", seat_massager); diff --git a/samples/graph/seat_massager_provider/src/main.rs b/samples/graph/seat_massager_provider/src/main.rs index 15ca8e51..4437b4d3 100644 --- a/samples/graph/seat_massager_provider/src/main.rs +++ b/samples/graph/seat_massager_provider/src/main.rs @@ -30,10 +30,11 @@ fn create_request_state() -> RequestState { // Create the seat massagers. let front_left_airbag_seat_massager_instance_id = "front_left_airbag_seat_massager".to_string(); - let front_left_airbag_seat_massager: sdv::premium_airbag_seat_massager::TYPE = sdv::premium_airbag_seat_massager::TYPE { - instance_id: front_left_airbag_seat_massager_instance_id.clone(), - ..Default::default() - }; + let front_left_airbag_seat_massager: sdv::premium_airbag_seat_massager::TYPE = + sdv::premium_airbag_seat_massager::TYPE { + instance_id: front_left_airbag_seat_massager_instance_id.clone(), + ..Default::default() + }; result.instance_map.insert( front_left_airbag_seat_massager_instance_id.to_string(), InstanceData { @@ -41,13 +42,15 @@ fn create_request_state() -> RequestState { description: sdv::premium_airbag_seat_massager::DESCRIPTION.to_string(), serialized_value: serde_json::to_string(&front_left_airbag_seat_massager).unwrap(), }, - ); + ); - let front_right_airbag_seat_massager_instance_id = "front_right_airbag_seat_massager".to_string(); - let front_right_airbag_seat_massager: sdv::premium_airbag_seat_massager::TYPE = sdv::premium_airbag_seat_massager::TYPE { - instance_id: front_right_airbag_seat_massager_instance_id.clone(), - ..Default::default() - }; + let front_right_airbag_seat_massager_instance_id = + "front_right_airbag_seat_massager".to_string(); + let front_right_airbag_seat_massager: sdv::premium_airbag_seat_massager::TYPE = + sdv::premium_airbag_seat_massager::TYPE { + instance_id: front_right_airbag_seat_massager_instance_id.clone(), + ..Default::default() + }; result.instance_map.insert( front_right_airbag_seat_massager_instance_id.to_string(), InstanceData { @@ -58,10 +61,11 @@ fn create_request_state() -> RequestState { ); let back_left_airbag_seat_massager_instance_id = "back_left_airbag_seat_massager".to_string(); - let back_left_airbag_seat_massager: sdv::basic_airbag_seat_massager::TYPE = sdv::basic_airbag_seat_massager::TYPE { - instance_id: back_left_airbag_seat_massager_instance_id.clone(), - ..Default::default() - }; + let back_left_airbag_seat_massager: sdv::basic_airbag_seat_massager::TYPE = + sdv::basic_airbag_seat_massager::TYPE { + instance_id: back_left_airbag_seat_massager_instance_id.clone(), + ..Default::default() + }; result.instance_map.insert( back_left_airbag_seat_massager_instance_id.to_string(), InstanceData { @@ -69,13 +73,15 @@ fn create_request_state() -> RequestState { description: sdv::basic_airbag_seat_massager::DESCRIPTION.to_string(), serialized_value: serde_json::to_string(&back_left_airbag_seat_massager).unwrap(), }, - ); + ); - let back_center_airbag_seat_massager_instance_id = "back_center_airbag_seat_massager".to_string(); - let back_center_airbag_seat_massager: sdv::basic_airbag_seat_massager::TYPE = sdv::basic_airbag_seat_massager::TYPE { - instance_id: back_center_airbag_seat_massager_instance_id.clone(), - ..Default::default() - }; + let back_center_airbag_seat_massager_instance_id = + "back_center_airbag_seat_massager".to_string(); + let back_center_airbag_seat_massager: sdv::basic_airbag_seat_massager::TYPE = + sdv::basic_airbag_seat_massager::TYPE { + instance_id: back_center_airbag_seat_massager_instance_id.clone(), + ..Default::default() + }; result.instance_map.insert( back_center_airbag_seat_massager_instance_id.to_string(), InstanceData { @@ -86,10 +92,11 @@ fn create_request_state() -> RequestState { ); let back_right_airbag_seat_massager_instance_id = "back_right_airbag_seat_massager".to_string(); - let back_right_airbag_seat_massager: sdv::basic_airbag_seat_massager::TYPE = sdv::basic_airbag_seat_massager::TYPE { - instance_id: back_right_airbag_seat_massager_instance_id.clone(), - ..Default::default() - }; + let back_right_airbag_seat_massager: sdv::basic_airbag_seat_massager::TYPE = + sdv::basic_airbag_seat_massager::TYPE { + instance_id: back_right_airbag_seat_massager_instance_id.clone(), + ..Default::default() + }; result.instance_map.insert( back_right_airbag_seat_massager_instance_id.to_string(), InstanceData { @@ -154,7 +161,8 @@ async fn main() -> Result<(), Box> { info!("The Seat Massager Provider has started."); - let settings = provider_config::load_settings_with_config_filename("seat_massager_provider_settings"); + let settings = + provider_config::load_settings_with_config_filename("seat_massager_provider_settings"); let provider_authority = settings.provider_authority; diff --git a/samples/graph/vehicle_core_provider/src/main.rs b/samples/graph/vehicle_core_provider/src/main.rs index c262eb38..e577a7fc 100644 --- a/samples/graph/vehicle_core_provider/src/main.rs +++ b/samples/graph/vehicle_core_provider/src/main.rs @@ -29,13 +29,15 @@ fn create_request_state() -> RequestState { // Seat massager ids. - let front_left_airbag_seat_massager_instance_id = "front_left_airbag_seat_massager".to_string(); + let front_left_airbag_seat_massager_instance_id = "front_left_airbag_seat_massager".to_string(); - let front_right_airbag_seat_massager_instance_id = "front_right_airbag_seat_massager".to_string(); + let front_right_airbag_seat_massager_instance_id = + "front_right_airbag_seat_massager".to_string(); - let back_left_airbag_seat_massager_instance_id = "back_left_airbag_seat_massager".to_string(); + let back_left_airbag_seat_massager_instance_id = "back_left_airbag_seat_massager".to_string(); - let back_center_airbag_seat_massager_instance_id = "back_center_airbag_seat_massager".to_string(); + let back_center_airbag_seat_massager_instance_id = + "back_center_airbag_seat_massager".to_string(); let back_right_airbag_seat_massager_instance_id = "back_right_airbag_seat_massager".to_string(); @@ -139,7 +141,7 @@ fn create_request_state() -> RequestState { sdv::cabin::seat::RELATIONSHIP_TYPE { instance_id: front_right_seat_instance_id.to_string(), seat_row: 1, - seat_position: sdv::cabin::seat::SEAT_POSITION_TYPE::right, + seat_position: sdv::cabin::seat::SEAT_POSITION_TYPE::right, }, sdv::cabin::seat::RELATIONSHIP_TYPE { instance_id: back_left_seat_instance_id.to_string(),