Skip to content

Add builder registration feature enable#3

Open
MonikaKumari26 wants to merge 14 commits into
stmuench:initial_rust_api_implementation_for_diag_libfrom
MonikaKumari26:builder-registration-feature
Open

Add builder registration feature enable#3
MonikaKumari26 wants to merge 14 commits into
stmuench:initial_rust_api_implementation_for_diag_libfrom
MonikaKumari26:builder-registration-feature

Conversation

@MonikaKumari26

Copy link
Copy Markdown

This PR adds the builder registration feature to enable dynamic builder registration in the diagnostics library. Implemented builder registration mechanism and Included comprehensive tests

@MonikaKumari26 MonikaKumari26 force-pushed the builder-registration-feature branch 3 times, most recently from 345953a to 4a798ee Compare May 29, 2026 14:26
@MonikaKumari26 MonikaKumari26 force-pushed the builder-registration-feature branch from 4a798ee to a56dee3 Compare May 29, 2026 14:33
@MonikaKumari26 MonikaKumari26 marked this pull request as ready for review June 10, 2026 08:46

@bharatGoswami8 bharatGoswami8 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some General Suggestion and I feel we can optimize builder pattern, as we are constructing same type as build type to build the type, can't we avoid this using trait based approach ?

pub mod sovd {
/// cf. ISO 17978-3:2025 Section 7.9.1, Table 70
#[derive(Clone, Debug, PartialEq)]
pub enum DataCategory {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how moving this into common file ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataCategory is to classify the SOVD data resources that's why it is here. The common module is intentionally kept to types that are shared across both SOVD and UDS.

Comment on lines 25 to 30
pub mod uds {
pub use common::uds::*;
pub use uds::*;
pub use uds_adapters::*;
pub use registration::*;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
pub mod uds {
pub use crate::{
common::uds::*,
uds_adapters::*,
registration::*,
};
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate the style suggestion !! However, pub use crate:: cannot be used here, check once the BUILD file.

Comment on lines 14 to 23
pub type KeyValueAttributes = ::common::KeyValueAttributes;
pub type ReplyMessageEncoding = ::common::ReplyMessageEncoding;
pub type ReplyMessagePayload = ::common::ReplyMessagePayload;
pub type RequestMessagePayload = ::common::RequestMessagePayload;
pub type DiagnosticReply = ::common::DiagnosticReply;
pub type ByteVector = ::common::ByteVector;
pub type JsonSchema = ::common::JsonSchema;
pub type Result<T> = ::common::Result<T>;
pub type ErrorCode = ::common::ErrorCode;
pub type Error = ::common::Error;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this alias is not in common ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's there.

* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

use common::Result as DiagResult;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not in common file?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a private module local alias, nothing to add in common

}

/// cf. ISO 17978-3:2025 Section 7.14.7, Table 186
pub type ExecutionId = String;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this type aliasing should be in some other file kike common.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

concept specific to SOVD operation execution lifecycle..

}

/// cf. ISO 17978-3:2025 Section 7.14.7, Table 186
pub type ExecutionId = String;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not new type pub struct ExecutionId(String)

@MonikaKumari26 MonikaKumari26 Jun 15, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment should be relevant to this PR : eclipse-score#2

#[must_use]
pub fn default() -> Self {
Self {
last_executed_capability: "n/a".to_string(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about using Option<String> ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

/// Kind type for events delivered to an operation's execution control loop.
/// Maps to the SOVD capability model (cf. ISO 17978-3:2025 Section 7.14.9).
#[derive(Clone)]
pub enum ExecutionEventKind {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can create one enum module and keep it there ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create one trait Builder and implement for the type DiagnosticServicesCollectionBuilder

pub trait Builder<Output> {
fn build(self) -> Result<Output>;
}

impl Builder<DiagnosticServicesCollectionBuilder> for DiagnosticServicesCollectionBuilder
{
...
}

with this you can make Builder trait as a super trait for other trait and create dependency.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion... Builder trait would only be beneficial if something needs to accept builders polymorphically, example a function taking T: Builder. In the design there is no such consumer. Here the ServiceRegistrar receives the finished collection, not the builder, so there is no call site where a Builder bound is needed as of now..

Comment thread score/mw/diag/api/registration.rs Outdated
/// Entity-agnostic builder for UDS diagnostic services (DIDs and routines)
#[derive(Default)]
pub struct UdsServicesCollectionBuilder {
read_dids: IndexMap<String, Box<dyn ReadDataByIdentifier + Send + 'static>>,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the above read field type is Sync bound, why not this ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed the inconsistency

@MonikaKumari26

Copy link
Copy Markdown
Author

Some General Suggestion and I feel we can optimize builder pattern, as we are constructing same type as build type to build the type, can't we avoid this using trait based approach ?

A trait-based approach would add a layer of abstraction without any performance gain, because the builder must hold heterogeneous instances which are incompatible with typestate patterns and also the builder is always constructed, populated and consumed in a single chain..

Happy to discuss further if you had a specific shape in mind..

@MonikaKumari26

MonikaKumari26 commented Jun 15, 2026

Copy link
Copy Markdown
Author
registration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants