pub struct SourceHostState {
pub table: ResourceTable,
pub wasi: WasiCtx,
pub request_rx: Arc<Mutex<Receiver<(HttpMeta, Receiver<Result<Bytes, CamelError>>)>>>,
pub exchange_tx: Sender<(Exchange, Sender<SubmitOutcome>)>,
pub cancel_token: CancellationToken,
pub max_request_body_bytes: u64,
}Expand description
Host state for a source consumer. Lives inside the wasmtime::Store.
Separate from crate::runtime::WasmHostState because the source world
has a fundamentally different lifecycle: the guest IS the source, owns a
run loop, and communicates via channels rather than direct call-process.
request_rx is wrapped in Arc<tokio::sync::Mutex<…>> because the async
host imports receive &Accessor (shared access), not &mut self; the
Mutex provides the interior mutability needed to recv().await the
receiver across import calls.
Fields§
§table: ResourceTable§wasi: WasiCtx§request_rx: Arc<Mutex<Receiver<(HttpMeta, Receiver<Result<Bytes, CamelError>>)>>>§exchange_tx: Sender<(Exchange, Sender<SubmitOutcome>)>§cancel_token: CancellationToken§max_request_body_bytes: u64Maximum bytes the guest may read from a single request body before
the stream producer terminates with an overflow error. Restores the
DoS backstop that the old to_bytes(MAX_BODY_BYTES) path provided.
Trait Implementations§
Source§impl Host for SourceHostState
impl Host for SourceHostState
Source§fn is_cancelled(&mut self) -> bool
fn is_cancelled(&mut self) -> bool
Source§impl HostHttpListener for SourceHostState
impl HostHttpListener for SourceHostState
Source§impl HostWithStore<SourceHostState> for HasSelf<SourceHostState>
Async host imports. The guest’s run (async) awaits these; each receives
&Accessor<SourceHostState, HasSelf<SourceHostState>> (shared access into
the store, NOT &mut self). We snapshot owned values (clones) out of a
with call, then .await OUTSIDE it — Accessor::with is sync and must
not be held across an await. Cancellation races every await against the
shared CancellationToken so stop() unblocks a parked import promptly.
impl HostWithStore<SourceHostState> for HasSelf<SourceHostState>
Async host imports. The guest’s run (async) awaits these; each receives
&Accessor<SourceHostState, HasSelf<SourceHostState>> (shared access into
the store, NOT &mut self). We snapshot owned values (clones) out of a
with call, then .await OUTSIDE it — Accessor::with is sync and must
not be held across an await. Cancellation races every await against the
shared CancellationToken so stop() unblocks a parked import promptly.
Source§async fn accept_http(
accessor: &Accessor<SourceHostState, HasSelf<SourceHostState>>,
_listener: Resource<HttpListenerHandle>,
) -> Result<Option<HttpRequest>, WasmError>
async fn accept_http( accessor: &Accessor<SourceHostState, HasSelf<SourceHostState>>, _listener: Resource<HttpListenerHandle>, ) -> Result<Option<HttpRequest>, WasmError>
awaits, yielding back to the host until a request arrives (or the run
is cancelled). The body is a stream-body-handle — the guest reads
incrementally via stream<u8>.read, removing the materialization cap.Source§async fn submit_exchange(
accessor: &Accessor<SourceHostState, HasSelf<SourceHostState>>,
exchange: WasmExchange,
) -> Result<SubmitOutcome, WasmError>
async fn submit_exchange( accessor: &Accessor<SourceHostState, HasSelf<SourceHostState>>, exchange: WasmExchange, ) -> Result<SubmitOutcome, WasmError>
run alive
while a submitted body stream is still draining; the stream’s terminal
future resolves when the body finished.Source§impl WasiView for SourceHostState
impl WasiView for SourceHostState
Source§fn ctx(&mut self) -> WasiCtxView<'_>
fn ctx(&mut self) -> WasiCtxView<'_>
WasiCtx configuration used for this
context.Auto Trait Implementations§
impl !RefUnwindSafe for SourceHostState
impl !Sync for SourceHostState
impl !UnwindSafe for SourceHostState
impl Freeze for SourceHostState
impl Send for SourceHostState
impl Unpin for SourceHostState
impl UnsafeUnpin for SourceHostState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more