add split traits to fill functionality gaps in downstream crates - #748
Open
celogic wants to merge 1 commit into
Open
add split traits to fill functionality gaps in downstream crates#748celogic wants to merge 1 commit into
celogic wants to merge 1 commit into
Conversation
Member
|
Splitting semantics get tricky, you haven't accounted for anything beyond just splitting (think: configuration that affects both sides etc) . I also don't believe this is a e-hal specific problem so I'm not sure it belongs here. |
Member
|
I got some concerns:
trait BorrowedSplit {
type Reader<'a>: Read where Self: 'a;
type Writer<'a>: Write where Self: 'a;
fn split_rw(&mut self) -> (Self::Reader<'_>, Self::Writer<'_>);
}
trait OwnedSplit {
type Reader: Read;
type Writer: Write;
fn split_rw(self) -> (Self::Reader, Self::Writer);
}
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
SplitRWtrait for both async and non async versions.It abstracts the capability, making them available for downstream libraries.
std::io::Split, which is anIteratorSplitRWdoesn't requireRead+Write, because i don't think its necessary and leaves the implementor more flexibleExample:
embedded_tls::TlsConnectionbuilds on (abstract)<Socket: embedded_io_async::Read + embedded_io_async::Write>.embedded_tls::TlsConnectionimpl the fnsplit, but it requiresSocket: Clone.this is not effective as
Socketdoesn't need to be completely cloned, which causes functionality gaps.e.g. if i use
embassy_net::tcp::TcpSocketas the underlayingSocket, I cant callTlsConnection::split,because
embassy_net::tcp::TcpSocketdoesn't implClone, despite providingsplititself