Skip to content

Commit

Permalink
Make HostOutgoingBody::body_output_stream non public
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
  • Loading branch information
rylev committed Apr 12, 2024
1 parent 02ace62 commit 17e9a4c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion crates/wasi-http/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ impl WrittenState {
/// The concrete type behind a `wasi:http/types/outgoing-body` resource.
pub struct HostOutgoingBody {
/// The output stream that the body is written to.
pub body_output_stream: Option<Box<dyn HostOutputStream>>,
body_output_stream: Option<Box<dyn HostOutputStream>>,
context: StreamContext,
written: Option<WrittenState>,
finish_sender: Option<tokio::sync::oneshot::Sender<FinishMessage>>,
Expand Down Expand Up @@ -488,6 +488,11 @@ impl HostOutgoingBody {
)
}

/// Take the output stream, if it's available.
pub fn take_output_stream(&mut self) -> Option<Box<dyn HostOutputStream>> {
self.body_output_stream.take()
}

/// Finish the body, optionally with trailers.
pub fn finish(mut self, trailers: Option<FieldMap>) -> Result<(), types::ErrorCode> {
// Make sure that the output stream has been dropped, so that the BodyImpl poll function
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-http/src/types_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ impl<T: WasiHttpView> crate::bindings::http::types::HostOutgoingBody for T {
id: Resource<HostOutgoingBody>,
) -> wasmtime::Result<Result<Resource<OutputStream>, ()>> {
let body = self.table().get_mut(&id)?;
if let Some(stream) = body.body_output_stream.take() {
if let Some(stream) = body.take_output_stream() {
let id = self.table().push_child(stream, &id)?;
Ok(Ok(id))
} else {
Expand Down

0 comments on commit 17e9a4c

Please sign in to comment.