Skip to content
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

Add an API similar to GDBusMessage::from_blob #326

Closed
zeenix opened this issue Mar 16, 2023 · 4 comments · Fixed by #370
Closed

Add an API similar to GDBusMessage::from_blob #326

zeenix opened this issue Mar 16, 2023 · 4 comments · Fixed by #370

Comments

@zeenix
Copy link
Contributor

zeenix commented Mar 16, 2023

In GitLab by @SeaDve on Mar 16, 2023, 15:44

Currently, there is zbus::Message::from_raw_parts. However, it is private.

For the use case, Bustle has DBus messages serialized in a pcap file. There is currently not a convenient way to parse the bytes from each packet from the pcap file into a zbus::Message.

Link

@zeenix
Copy link
Contributor Author

zeenix commented Mar 16, 2023

Thanks for reporting this but I guess I wasn't clear on the matrix channel when we discussed this. I don't need to consider this, I think we should provide such an API. I suggested we make zbus::Message::from_raw_parts public as part of MessageBuilder. Would it be possible to provide a MR?

@zeenix
Copy link
Contributor Author

zeenix commented Mar 16, 2023

In GitLab by @SeaDve on Mar 16, 2023, 16:07

Ahhh. yeah, sure

@SeaDve
Copy link
Contributor

SeaDve commented Jun 5, 2023

I'm sorry if I took too long to get back to this.

I am a bit puzzled about how the API should look, but my understanding of what you suggested is to have something like this, or should it be something different like returning the Builder, instead?

impl MessageBuilder {
    pub fn from_raw_parts(bytes: Vec<u8>, ...) -> Message {
        ...
    }
}

@zeenix
Copy link
Contributor Author

zeenix commented Jun 5, 2023

I am a bit puzzled about how the API should look, but my understanding of what you suggested is to have something like this, or should it be something different like returning the Builder, instead?

Out of pure coincidence I had to use something similar myself yesterday in busd code to create a modified copy of a message. There I used MessageBuilder::build_raw_body combined with TryFrom<MessageHeader> for MessageBuilder impl I just added yesterday. However that's more building messages from separate parts instead.

For building a full Message from raw bytes. I'd just add a TryFrom<&[u8]> impl for Message.

SeaDve added a commit to SeaDve/zbus that referenced this issue Jun 6, 2023
SeaDve added a commit to SeaDve/zbus that referenced this issue Jun 7, 2023
SeaDve added a commit to SeaDve/zbus that referenced this issue Jun 11, 2023
SeaDve added a commit to SeaDve/zbus that referenced this issue Jun 11, 2023
SeaDve added a commit to SeaDve/zbus that referenced this issue Jun 12, 2023
SeaDve added a commit to SeaDve/zbus that referenced this issue Jun 12, 2023
luukvanderduim pushed a commit to luukvanderduim/zbus that referenced this issue Jun 16, 2023
MaxVerevkin pushed a commit to MaxVerevkin/zbus that referenced this issue Jun 20, 2023
SeaDve added a commit to SeaDve/zbus that referenced this issue Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants