-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sample api rework #858
Sample api rework #858
Conversation
2 similar comments
Sample builder uses generics
…to sample_api_rework
{ | ||
self.encoding = encoding.into(); | ||
self | ||
impl ValueBuilderTrait for Value { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Value
has not been ported yet to accessor pattern.
By implementing ValueBuilderTrait
directly on Value
we will have a conflict in terms of functions.
With accessor pattern:
let payload: &Payload = value.payload();
With builder pattern:
value = value.payload("foo");
Do we really need to implement ValueBuilderTrait
on Value
itself or could we have a ValueBuilder
as we do with a SampleBuilder
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think yes, the separate builder wrapper structure is the only way to have same names for builder parameters and for data accessors. So if we have this SampleBuilder
, the ValueBuilder
should appear too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I think it's would be easier to make value accessors and value builder in a separate PR
Sample api rework update
Closes #837
The API changes proposed by this request are:
Depending on the component, specific traits are implemented. For example builder for
Session::put
operation mplementsQoSBuilderTrait + SampleBuilderTrait + ValueBuilderTrait
, but builder forPublisher::delete
implements onlySampleBuilderTrait
, because priority is set in publisher itself (traitQoSBuilderTrait
is implemented by thePublisherBuilder
) andencoding
andpayload
are not sent on delete operation.This allows to guarantee consistent support of sample data in different components.
TimestampBuilderTrait
is separate becauseget
operation doesn't support sending timestamp, so it was necessary to detach this function from othersSample
structure. Implemented buildersSampleBuilder
,PutSampleBuilder
,DeleteSampleBuilder
instead. These builders may be constructed either empty or from existing sample. They are implemented as a wrappers aroundSample
, so sample can be edited on place.Example: