Support for reading cached properties without delay
It is useful to be able to read the properties of an object in contexts where you cannot incur the delay of a round-trip to the remote party providing the object (for example, while rendering graphics). While property caching provides this behavior, it is currently not obvious (at a type level) if this is enabled, nor is it documented that having caching enabled results in reads always making no round-trips.
Ideally I would like a sync interface (that is, one which does not internally call block_on
) that gets a (possibly outdated) value of a cached property. An error like PropertyNotCached
could be used to denote that the async or blocking interface must be used (which would presumably need to actually make a call the remote party).
This should be doable by changing the Mutex on the property cache to a std::sync::Mutex
(or rwlock) and, if needed, having a separate async Mutex
act as a write-lock if you need to serialize changes (though I do not see a need for this - updates are delivered as a Message
and don't need any async functions to parse and update).
Current high-level API thoughts: keep async fn property(&self)
for the existing behavior and allow adding fn cached_property(&self)
for the cached version? It looks like set_
as a prefix is already reserved; cached_
could do the same, or it could be an attribute like #[dbus_proxy(property,cached)]
if you think dbus properties called CachedFoo
are more common than ones called SetFoo
. Obviously only a getter can be cached.