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 read_from_packed_stream to make reading individual packed messages easier #33

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ObsidianMinor
Copy link
Collaborator

In practice, having to make a PackedStream, call read_packed_from_stream, then call .finish() on the stream just to read a single message is really annoying. It's useful to have it be separate, but reading a single self-contained message from a stream (like a slice or something similar) is pretty common. So this changes the API slightly to make reading a single message easy.

@ObsidianMinor ObsidianMinor requested a review from a team as a code owner October 29, 2024 22:21
@johnhurt
Copy link
Contributor

Wooo

/// Read a message from a `PackedStream`. This allows you to continue reading more packed
/// data after the stream and reuse the packed state.
#[cfg(feature = "std")]
pub fn read_with_packed_stream<R: io::BufRead>(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find name difference very insignificant and as a result I have no idea which one to use based on the name.
Can we differentiate these two more? Maybe with doesn't need to be pub?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention is that "with" implies you're using an existing thing, "from" implies you're consuming the thing completely. "with" needs to be pub because you could have a stream of multiple packed messages or general packed data. You want to keep the PackedStream state around so you can read more stuff.

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 this pull request may close these issues.

3 participants