pub struct Fetcher(/* private fields */);Expand description
A struct for invoking fetch events to other Workers.
Implementations§
Source§impl Fetcher
impl Fetcher
Sourcepub async fn fetch(
&self,
url: impl Into<String>,
init: Option<RequestInit>,
) -> Result<HttpResponse>
pub async fn fetch( &self, url: impl Into<String>, init: Option<RequestInit>, ) -> Result<HttpResponse>
Invoke a fetch event in a worker with a url and optionally a RequestInit.
Return type is Response unless http feature is enabled
and then it is http::Response<worker::Body>.
Sourcepub async fn fetch_request<T, E>(&self, request: T) -> Result<HttpResponse>
pub async fn fetch_request<T, E>(&self, request: T) -> Result<HttpResponse>
Invoke a fetch event with an existing Request.
Argument type is Request or http::Request<worker::Body>.
Return type is Response unless http feature is enabled
and then it is http::Response<worker::Body>.
Sourcepub fn into_rpc<T: JsCast>(self) -> T
pub fn into_rpc<T: JsCast>(self) -> T
Convert Fetcher into user-defined RPC interface.
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(extends=js_sys::Object)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub type MyRpcInterface;
#[wasm_bindgen(method, catch)]
pub fn add(
this: &MyRpcInterface,
a: u32,
b: u32,
) -> std::result::Result<js_sys::Promise, JsValue>;
}
let rpc: MyRpcInterface = fetcher.into_rpc();
let result = rpc.add(1, 2);Trait Implementations§
Source§impl EnvBinding for Fetcher
impl EnvBinding for Fetcher
Source§impl JsCast for Fetcher
impl JsCast for Fetcher
Source§fn instanceof(val: &JsValue) -> bool
fn instanceof(val: &JsValue) -> bool
Performs a dynamic
instanceof check to see whether the JsValue
provided is an instance of this type. Read moreSource§fn unchecked_from_js(val: JsValue) -> Self
fn unchecked_from_js(val: JsValue) -> Self
Source§fn unchecked_from_js_ref(val: &JsValue) -> &Self
fn unchecked_from_js_ref(val: &JsValue) -> &Self
Source§fn has_type<T>(&self) -> boolwhere
T: JsCast,
fn has_type<T>(&self) -> boolwhere
T: JsCast,
Test whether this JS value has a type
T. Read moreSource§fn dyn_into<T>(self) -> Result<T, Self>where
T: JsCast,
fn dyn_into<T>(self) -> Result<T, Self>where
T: JsCast,
Performs a dynamic cast (checked at runtime) of this value into the
target type
T. Read moreSource§fn dyn_ref<T>(&self) -> Option<&T>where
T: JsCast,
fn dyn_ref<T>(&self) -> Option<&T>where
T: JsCast,
Performs a dynamic cast (checked at runtime) of this value into the
target type
T. Read moreSource§fn unchecked_into<T>(self) -> Twhere
T: JsCast,
fn unchecked_into<T>(self) -> Twhere
T: JsCast,
Performs a zero-cost unchecked cast into the specified type. Read more
Source§fn unchecked_ref<T>(&self) -> &Twhere
T: JsCast,
fn unchecked_ref<T>(&self) -> &Twhere
T: JsCast,
Performs a zero-cost unchecked cast into a reference to the specified
type. Read more
Auto Trait Implementations§
impl Freeze for Fetcher
impl RefUnwindSafe for Fetcher
impl Send for Fetcher
impl Sync for Fetcher
impl Unpin for Fetcher
impl UnsafeUnpin for Fetcher
impl UnwindSafe for Fetcher
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> TryFromJsValue for Twhere
T: JsCast,
impl<T> TryFromJsValue for Twhere
T: JsCast,
Source§impl<S, T> Upcast<T> for S
impl<S, T> Upcast<T> for S
Source§impl<T> VectorRefIntoWasmAbi for T
impl<T> VectorRefIntoWasmAbi for T
Source§fn slice_into_abi(slice: &[T]) -> WasmSlice
fn slice_into_abi(slice: &[T]) -> WasmSlice
Construct the wire representation for
Some(slice). The returned
WasmSlice is either a borrow of the input slice (primitive
case) or a buffer JS owns and frees (handle-shaped case).Source§fn slice_none() -> WasmSlicewhere
Self: Sized,
fn slice_none() -> WasmSlicewhere
Self: Sized,
Wire representation for
None (used by Option<&[T]>). A null
WasmSlice (ptr == 0) is the convention shared with every
other vector-like ABI in the crate.