Rust::com Field APIs design for rust com library#638
Conversation
* Created seperate crate for field APIs * SampleMut updated based making common for Event and Field
* Updated SampleMut trait * Created impl for field trait * Updated API documentation
6d5faf9 to
5d851e1
Compare
| pub use com_api_runtime_lola::RuntimeBuilderImpl as LolaRuntimeBuilderImpl; | ||
| pub use com_api_runtime_mock::MockRuntimeImpl; | ||
| pub use com_api_runtime_mock::RuntimeBuilderImpl as MockRuntimeBuilderImpl; | ||
| // pub use com_api_runtime_mock::MockRuntimeImpl; |
There was a problem hiding this comment.
This is just commented for now, we will enable it before PR open for review
There was a problem hiding this comment.
This is not optimized yet, just for building purpose added separate field related macro implementation, will optimize this.
| exhaust: Event<Exhaust>, | ||
| } | ||
| ); | ||
|
|
There was a problem hiding this comment.
macro need to be optimize.
| let producer = producer_builder | ||
| .build() | ||
| .expect("Failed to build producer instance"); | ||
| producer |
There was a problem hiding this comment.
Should we take initial value in FieldPublisher::new(...,value) so that field will always have default value and user no need to explicitly call update.
| interface!( | ||
| interface VehicleField, { | ||
| Id = "VehicleFieldInterface", | ||
| left_tire: Field<Tire>, |
There was a problem hiding this comment.
left_tire : Field<Tire, Initial_value, NotifyOnSet>
| // Value return from C++ side is reference of FieldType. | ||
| let value: &Tire = producer | ||
| .left_tire | ||
| .register_set_handler() |
There was a problem hiding this comment.
Can be done using macro parameter , in that case we need to have one more parameter for future type in producer /offerproducer struct.
| let _ = subscription | ||
| .set(Tire { pressure: 35.0 }) | ||
| .expect("Failed to set field value"); | ||
| let _ = subscription.get().expect("Failed to get field value"); |
There was a problem hiding this comment.
Should we use with consumer instance only rather using from subscription type, in that case consumer should not move in subscribe call.
* Update the intial value for field in macro
1d4f5e7 to
68e8bf3
Compare
|
|
||
| // Field intialize the intial value based on the default value of the field type at the time of creating field publisher. | ||
| // If user want to update the value after that as well then they can use update method of the field publisher to update the value of the field. | ||
| interface!( |
There was a problem hiding this comment.
We need thread pool count for each field which can be part of macro.
left_tire : Field<Tire, Count>
68e8bf3 to
6dc14b7
Compare
| //currently we do not have MethodReturnTypePtr implementation for Lola runtime. | ||
|
|
||
| //If user did not get the insatnce before the subscribe call then consumer will be consumed. | ||
| let field_method = consumer.get_field_method_instance(); |
There was a problem hiding this comment.
consumer.left_tire.get_field_method_instance();
There was a problem hiding this comment.
Left_tire_method
No description provided.