feat(dvc): expose dynamic channel accessors#1368
Conversation
There was a problem hiding this comment.
Thank you!
This API feels a bit implementation-shaped to me. The use case we want to support is "given a DVC channel id, recover my typed processor so I can call its domain-specific API mutably." But exposing DynamicChannel directly seems to expose the current storage and lifecycle wrapper as part of the public contract.
Just thinking out loud, but maybe we could make the public API narrower and more intention-shaped instead, e.g. typed processor accessors on DrdynvcClient / DrdynvcServer, while keeping the channel wrapper types private?
Also, the new DvcClientProcessor bound seems inconsistent with registration: client APIs still accept T: DvcProcessor and listeners return Box<dyn DvcProcessor>, but downcasting now requires T: DvcClientProcessor. Maybe registration/listener APIs should also use DvcClientProcessor, or the downcast bound should remain DvcProcessor?
Thanks, that makes sense to me. I exposed
Agreed, so the API looks like
Thanks for pointing out, will be resolved in this PR. |
9f2fd45 to
9d2a0d3
Compare
|
Benoît Cortier (@CBenoit) I reserve my perspective after I tried to modify the client I think there is a valid public use case for a channel handle: callers sometimes need the channel id and the typed processor together. Splitting that into separate APIs such as That said, I agree with the concern that exposing the current channel wrapper exposes implementation shape:
The storage itself is not exposed while the fields stay private, but the current wrapper still exposes lifecycle/storage shape through the public type and the downcast-based accessor methods. Also, mutable processor access is the reason this PR exists, so some controlled mutable access to the underlying processor is unavoidable. I mentioned the original need here: #1137 (comment) Maybe the better API is to keep pub struct DvcAccessor<'a, T: DvcProcessor> {
channel_id: u32,
processor: &'a T,
}
pub struct DvcAccessorMut<'a, T: DvcProcessor> {
channel_id: u32,
processor: &'a mut T,
}Then |
dad3bed to
9cfe549
Compare
Add mutable dynamic channel lookup APIs for drdynvc server. Signed-off-by: uchouT <i@uchout.moe>
Add mutable dynamic channel lookup APIs for drdynvc client / server, so that we can use the public API with signature
&mut selfin dvc processor, such asUrbdrcDeviceClientandUrbdrcControlClientin #1365