-
Notifications
You must be signed in to change notification settings - Fork 6
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
Rename BusProperties::build
to BusProperties::from_message
and auto implement conversion for most User Facing Event Types.
#181
Comments
This sounds like a great plan! Should I do it? Or would you like to? |
You're very welcome to make this happen. It would fit nicely in your new-generic-event-trait branch. That being said, if you feel you are somewhat overburdened, I am happy to do it. I have time this week. |
BusProperties::build
to BusProperties::from_message
and auto implement conversion for most User Facing Event Typess.BusProperties::build
to BusProperties::from_message
and auto implement conversion for most User Facing Event Types.
All good; I got a new keyboard this week, and I need to break it in! |
In vein of our 'pair proramming' I took a longer look at the problem. Creating a type belongs to the type itself is the main takeaway I think. What we can have is
We could still reduce duplicate code somewhat by having
fn validate_msg(&self, msg: &zbus::Message) -> bool {
let header = msg.header();
// Safety: `from_str_unchecked` is fine because these are statically known values.
let member = MemberName::from_str_unchecked(Self::DBUS_MEMBER);
let interface = InterfaceName::from_str_unchecked(Self::DBUS_INTERFACE);
header.member() == Some(&member) && header.interface() == Some(&interface)
} If we end up just converting |
I think that there are some other issues that are not possible to fix due to compiler limitations. Not being able to apply a blanket implementation for Would that suffice? |
Our UFETs implement
BusProperties
(GenericEvent
) which provides:We define per-event how the UFET is constructed from (essentially) a
Message
because<T as BusProperties>::build
is employed infrom_dbus_message!
only.Observe that most UFETs do not even need a body, in that case the second argument in the signature is underscored
_body:
from_message
This will reduce a number of macro expansions, remove
impl_from_dbus_message
, remove howbuild
eludes to a builder pattern that is not there and simplifies most conversions by not needing to define them I think.The text was updated successfully, but these errors were encountered: