pub struct InputContext { /* private fields */ }Expand description
Per-invocation input context. Owns the bytes the host staged for the
guest to pull via the wasi:tensor/host input-len / read-input
host functions.
This is the input counterpart to StreamingContext (which is
output-only, guest → host). The gateway stages the request payload —
e.g. the OpenAI completions shim stages the assembled prompt bytes —
before the guest runs, and the guest copies them into its own linear
memory.
Cloning is cheap: the bytes live behind an Arc<[u8]>, so a clone is
a single refcount bump. An empty context (InputContext::empty) is
the default for invocations the gateway did not stage input for —
len() is 0 and read-input copies nothing.
Implementations§
Source§impl InputContext
impl InputContext
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Construct an empty context. len() returns 0; read-input
copies nothing. This is the default for invocations the gateway
did not stage any input for.
Sourcepub fn new(bytes: impl Into<Arc<[u8]>>) -> Self
pub fn new(bytes: impl Into<Arc<[u8]>>) -> Self
Construct a context wrapping the given staged input bytes.
Trait Implementations§
Source§impl Clone for InputContext
impl Clone for InputContext
Source§fn clone(&self) -> InputContext
fn clone(&self) -> InputContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InputContext
impl Debug for InputContext
Source§impl Default for InputContext
impl Default for InputContext
Source§fn default() -> InputContext
fn default() -> InputContext
Auto Trait Implementations§
impl Freeze for InputContext
impl RefUnwindSafe for InputContext
impl Send for InputContext
impl Sync for InputContext
impl Unpin for InputContext
impl UnsafeUnpin for InputContext
impl UnwindSafe for InputContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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