pub struct Call { /* private fields */ }Expand description
A call of an exported function: its arguments, which are JSON values,
byte arrays and channels Rust lends to it, and the trusted Context of
its invocation.
let mut call = Call::new("transcode");
call.json(json!({ "format": "webm", "progress": null }));
call.bytes(source);
let progress = call.channel_at("/0/progress", app.limits())?;
call.context(Context::new().with(Tenant("a".into())));
let output = app.call_with(call).await?;JavaScript receives each byte array as a Uint8Array and each lent
channel as a channel object, with the opened, closed, socket() and
stream() of an env binding’s channel, at the argument position Rust
named; Rust keeps the ChannelEnd. Positions are JSON Pointers into
the argument list, so no JSON shape is reserved for them. A lent channel
belongs to the call’s invocation and closes when it ends, as a channel
JavaScript opens does; it does not count against Limits::open_channels,
which bounds what JavaScript opens. Channels need the fetchlet Web API
profile, which builds the channel objects; without it the call fails.
The context reaches the Functions methods
JavaScript calls during the invocation, as
FunctionRequest::context, and its
host fetches, as the context of a Fetch request does. JavaScript cannot
read it.
Implementations§
Source§impl Call
impl Call
pub fn new(export: impl Into<String>) -> Self
Sourcepub fn bytes(&mut self, bytes: impl Into<Bytes>) -> &mut Self
pub fn bytes(&mut self, bytes: impl Into<Bytes>) -> &mut Self
Add a byte array argument, which JavaScript receives as a
Uint8Array.
Sourcepub fn bytes_at(
&mut self,
pointer: &str,
bytes: impl Into<Bytes>,
) -> Result<&mut Self>
pub fn bytes_at( &mut self, pointer: &str, bytes: impl Into<Bytes>, ) -> Result<&mut Self>
Put a byte array at pointer, a JSON Pointer into the argument list
such as /0/image, replacing the value there, as
channel_at lends a channel.
Sourcepub fn channel(&mut self, limits: &Limits) -> ChannelEnd
pub fn channel(&mut self, limits: &Limits) -> ChannelEnd
Add a channel argument and return Rust’s end of it. The channel’s
budgets come from limits: pass the App’s, as the channels
JavaScript opens have.
Sourcepub fn channel_at(
&mut self,
pointer: &str,
limits: &Limits,
) -> Result<ChannelEnd>
pub fn channel_at( &mut self, pointer: &str, limits: &Limits, ) -> Result<ChannelEnd>
Lend a channel at pointer, a JSON Pointer into the argument list
such as /0/progress, and return Rust’s end of it. The value there
must exist; the channel object replaces it. Fails with
InvalidRequest for a pointer that names no value, the list itself,
or a position inside or around another byte array or channel.
Sourcepub fn context(&mut self, context: Context) -> &mut Self
pub fn context(&mut self, context: Context) -> &mut Self
Attach trusted values to the call’s invocation, replacing any attached before.
pub fn export(&self) -> &str
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Call
impl !UnwindSafe for Call
impl Forget for Call
impl Freeze for Call
impl Move for Call
impl Send for Call
impl Sync for Call
impl Unpin for Call
impl UnsafeUnpin for Call
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<T> ErasedDestructor for Twhere
T: 'static,
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 moreimpl<T> ParallelSend for T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.