i.e. my bus_volts dataref doesn't store a value of its own, it's a float dataref that when you read it, it gives you something_volts if the switch is on otherwise zero.
Is there a way to do this kind of thing currently which I'm missing?
Was thinking maybe OwnedData should be split into a trait and a standard implementation. The trait would specify int_read, float_write etc functions which default to just returning None. The standard implementation would create a Box<T> and register read and optionally write functions for it. Whereas I'd just be impl OwnedData for FilteredBus and providing my own float_read function and not storing anything.
That makes sense. This library doesn't have a way to do that right now.
I don't have time to implement it myself right now, but the idea of a trait that OwnedData implements sounds good.
A feature I used a lot in my C++ days was to register new datarefs that basically acted as a filter on some other sources of data:
i.e. my
bus_volts
dataref doesn't store a value of its own, it's a float dataref that when you read it, it gives yousomething_volts
if the switch is on otherwise zero.Is there a way to do this kind of thing currently which I'm missing?
Was thinking maybe
OwnedData
should be split into a trait and a standard implementation. The trait would specifyint_read
,float_write
etc functions which default to just returningNone
. The standard implementation would create aBox<T>
and register read and optionally write functions for it. Whereas I'd just beimpl OwnedData for FilteredBus
and providing my ownfloat_read
function and not storing anything.