mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-25 17:01:20 +00:00
Add comment to wasm_ext::Connection (#1165)
This commit is contained in:
parent
a2550215a0
commit
012c5a948b
@ -302,6 +302,10 @@ impl Stream for Listen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Active stream of data with a remote.
|
/// Active stream of data with a remote.
|
||||||
|
///
|
||||||
|
/// It is guaranteed that each call to `io::Write::write` on this object maps to exactly one call
|
||||||
|
/// to `write` on the FFI. In other words, no internal buffering happens for writes, and data can't
|
||||||
|
/// be split.
|
||||||
pub struct Connection {
|
pub struct Connection {
|
||||||
/// The FFI object.
|
/// The FFI object.
|
||||||
inner: SendWrapper<ffi::Connection>,
|
inner: SendWrapper<ffi::Connection>,
|
||||||
@ -419,6 +423,9 @@ impl tokio_io::AsyncRead for Connection {
|
|||||||
|
|
||||||
impl io::Write for Connection {
|
impl io::Write for Connection {
|
||||||
fn write(&mut self, buf: &[u8]) -> Result<usize, io::Error> {
|
fn write(&mut self, buf: &[u8]) -> Result<usize, io::Error> {
|
||||||
|
// Note: as explained in the doc-comments of `Connection`, each call to this function must
|
||||||
|
// map to exactly one call to `self.inner.write()`.
|
||||||
|
|
||||||
if let Some(mut promise) = self.previous_write_promise.take() {
|
if let Some(mut promise) = self.previous_write_promise.take() {
|
||||||
match promise.poll().map_err(JsErr::from)? {
|
match promise.poll().map_err(JsErr::from)? {
|
||||||
Async::Ready(_) => (),
|
Async::Ready(_) => (),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user