/// # Panics /// /// If the `BufferedStream` is initialized more than once, it will panic. pubfn init(&mutself, stream_id: StreamId) {
debug_assert!(&Self::Uninitialized == self);
*self = Self::Initialized {
stream_id,
buf: Vec::new(),
};
}
/// # Panics /// /// This functon cannot be called before the `BufferedStream` is initialized. pubfn buffer(&mutself, to_buf: &[u8]) { ifletSelf::Initialized { buf, .. } = self {
buf.extend_from_slice(to_buf);
} else {
debug_assert!(false, "Do not buffer date before the stream is initialized");
}
}
/// # Errors /// /// Returns `neqo_transport` errors. pubfn send_buffer(&mutself, conn: &mut Connection) -> Res<usize> { let label = ::neqo_common::log_subject!(::log::Level::Debug, self); letSelf::Initialized { stream_id, buf } = selfelse { return Ok(0);
}; if buf.is_empty() { return Ok(0);
}
qtrace!([label], "sending data."); let sent = conn.stream_send(*stream_id, &buf[..])?; if sent == 0 { return Ok(0);
} elseif sent == buf.len() {
buf.clear();
} else { let b = buf.split_off(sent);
*buf = b;
}
qlog::h3_data_moved_down(conn.qlog_mut(), *stream_id, sent);
Ok(sent)
}
/// # Errors /// /// Returns `neqo_transport` errors. pubfn send_atomic(&mutself, conn: &mut Connection, to_send: &[u8]) -> Res<bool> { // First try to send anything that is in the buffer. self.send_buffer(conn)?; letSelf::Initialized { stream_id, buf } = selfelse { return Ok(false);
}; if !buf.is_empty() { return Ok(false);
} let res = conn.stream_send_atomic(*stream_id, to_send)?; if res {
qlog::h3_data_moved_down(conn.qlog_mut(), *stream_id, to_send.len());
}
Ok(res)
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.