-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat(api): writer & reader API #6
Conversation
Signed-off-by: iGxnon <igxnon@gmail.com>
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
benches/bulk.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bulk benchmark should be added back 😿
README.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewrite readme
@@ -194,13 +194,11 @@ where | |||
} | |||
} | |||
|
|||
impl<F> Sink<Frame> for OutgoingGuard<F> | |||
impl<F> Writer<Frame> for OutgoingGuard<F> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implement default methods in Writer for it.
// Send data to the destination | ||
async fn send(dst: Pin<&mut impl Writer<Message>>, data: impl Iterator<Item = u8>) { | ||
send_with_full(dst, data, Reliability::ReliableOrdered, 0).await; | ||
} | ||
|
||
async fn send_with_reliability( | ||
dst: Pin<&mut impl Writer<Message>>, | ||
data: impl Iterator<Item = u8>, | ||
reliability: Reliability, | ||
) { | ||
send_with_full(dst, data, reliability, 0).await; | ||
} | ||
|
||
async fn send_with_order( | ||
dst: Pin<&mut impl Writer<Message>>, | ||
data: impl Iterator<Item = u8>, | ||
order: u8, | ||
) { | ||
send_with_full(dst, data, Reliability::ReliableOrdered, order).await; | ||
} | ||
|
||
async fn send_with_full( | ||
mut dst: Pin<&mut impl Writer<Message>>, | ||
data: impl Iterator<Item = u8>, | ||
reliability: Reliability, | ||
order: u8, | ||
) { | ||
poll_fn(|cx| dst.as_mut().poll_ready(cx)).await.unwrap(); | ||
dst.as_mut() | ||
.feed(Message::new(reliability, order, Bytes::from_iter(data))); | ||
poll_fn(|cx| dst.as_mut().poll_flush(cx)).await.unwrap(); | ||
} | ||
|
||
async fn flush(mut dst: Pin<&mut impl Writer<Message>>) { | ||
poll_fn(|cx| dst.as_mut().poll_flush(cx)).await.unwrap(); | ||
} | ||
|
||
async fn close(mut dst: Pin<&mut impl Writer<Message>>) { | ||
poll_fn(|cx| dst.as_mut().poll_close(cx)).await.unwrap(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add WriterExt
/// Ping extension for client, experimental | ||
pub trait Ping { | ||
fn ping(self: Pin<&mut Self>) -> impl Future<Output = Result<(), Error>> + Send; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provide Ping
support for the client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, using WriterWrapper
.
Closed cz we have implemented the |
This PR changed the default API to use a more granular Writer API instead of the original Sink.
Signed-off-by: iGxnon igxnon@gmail.com