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

Any delimiter codec #3406

Merged
merged 7 commits into from
Feb 23, 2021
Merged

Any delimiter codec #3406

merged 7 commits into from
Feb 23, 2021

Conversation

r-zig
Copy link
Contributor

@r-zig r-zig commented Jan 11, 2021

Motivation

To provide codecs that can be used with custom delimiters and encoder characters. The codex will decide based on any character found in the given delimiter characters.

Solution

This will work similarly to LinesCodec by trying to find any of the characters while decoding , and appending all of the given characters while encoding.

@Darksonn Darksonn added A-tokio-util Area: The tokio-util crate M-codec Module: tokio-util/codec labels Jan 11, 2021
use simple &[u8] instead of &str and
remove requirment for 'static
tokio-util/src/codec/any_delimiter_codec.rs Outdated Show resolved Hide resolved
tokio-util/src/codec/any_delimiter_codec.rs Outdated Show resolved Hide resolved
tokio-util/src/codec/any_delimiter_codec.rs Outdated Show resolved Hide resolved
Change the Item to Bytes
and then discard all bytes till separator while returning Ok(None)
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

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

Looks correct to me 👍

@Darksonn Darksonn merged commit c9d2a36 into tokio-rs:master Feb 23, 2021
@r-zig r-zig deleted the delimiter-codec branch February 24, 2021 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio-util Area: The tokio-util crate M-codec Module: tokio-util/codec
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants