MCPcopy Create free account
hub / github.com/bytecodealliance/wstd / poll_frame

Method poll_frame

src/http/body.rs:440–480  ·  view source on GitHub ↗
(
        mut self: Pin<&mut Self>,
        cx: &mut Context<'_>,
    )

Source from the content-addressed store, hash-verified

438 type Data = Bytes;
439 type Error = Error;
440 fn poll_frame(
441 mut self: Pin<&mut Self>,
442 cx: &mut Context<'_>,
443 ) -> Poll<Option<Result<Frame<Self::Data>, Self::Error>>> {
444 loop {
445 let state = self.as_mut().state.take();
446 if state.is_none() {
447 return Poll::Ready(None);
448 }
449 let mut state = state.unwrap();
450 match state.as_mut().project() {
451 IBSProj::Body { read_state, body } => match read_state.poll_frame(cx) {
452 Poll::Pending => {
453 self.as_mut().state = Some(state);
454 return Poll::Pending;
455 }
456 Poll::Ready(Some(r)) => {
457 self.as_mut().state = Some(state);
458 return Poll::Ready(Some(r));
459 }
460 Poll::Ready(None) => {
461 // state contains children of the incoming-body. Must drop it
462 // in order to finish
463 let body = body.take().expect("finishing Body state");
464 drop(state);
465 let trailers_state = TrailersState::new(WasiIncomingBody::finish(body));
466 self.as_mut().state =
467 Some(Box::pin(IncomingBodyState::Trailers { trailers_state }));
468 continue;
469 }
470 },
471 IBSProj::Trailers { trailers_state } => match trailers_state.poll_frame(cx) {
472 Poll::Pending => {
473 self.as_mut().state = Some(state);
474 return Poll::Pending;
475 }
476 Poll::Ready(r) => return Poll::Ready(r),
477 },
478 }
479 }
480 }
481 fn is_end_stream(&self) -> bool {
482 self.state.is_none()
483 }

Callers 1

sendMethod · 0.80

Calls 5

header_map_from_wasiFunction · 0.85
scheduleMethod · 0.80
wait_forMethod · 0.80
readMethod · 0.45
pollMethod · 0.45

Tested by

no test coverage detected