pub struct JsRequest {
pub uri: String,
pub method: String,
pub body: Option<String>,
pub headers: HashMap<String, String>,
}
Expand description
Represents a request originating from JavaScript.
// JavaScript Example
import {JsRequest} from "my-wasm-app"
const jsRequest = new JsRequest("https://www.rust-lang.org/", "GET");
jsRequest.headers_append("Content-Type", "text/html");
// pass request to WASM app
Consume the request in Rust
use javascript_adapter::JsRequest;
#[wasm_bindgen]
pub fn app(js_request: JsRequest) {
// do things with js_request
}
Fields§
§uri: String
§method: String
§body: Option<String>
§headers: HashMap<String, String>
Implementations§
Source§impl JsRequest
impl JsRequest
pub fn new(uri: String, method: String) -> JsRequest
pub fn uri(&self) -> String
pub fn method(&self) -> String
pub fn body(&self) -> String
pub fn set_body(&mut self, body: String)
pub fn headers(&self) -> JsValue
pub fn headers_append(&mut self, key: String, value: String)
Trait Implementations§
Source§impl FromWasmAbi for JsRequest
impl FromWasmAbi for JsRequest
Source§impl IntoWasmAbi for JsRequest
impl IntoWasmAbi for JsRequest
Source§impl LongRefFromWasmAbi for JsRequest
impl LongRefFromWasmAbi for JsRequest
Source§impl OptionFromWasmAbi for JsRequest
impl OptionFromWasmAbi for JsRequest
Source§impl OptionIntoWasmAbi for JsRequest
impl OptionIntoWasmAbi for JsRequest
Source§impl RefFromWasmAbi for JsRequest
impl RefFromWasmAbi for JsRequest
Source§impl RefMutFromWasmAbi for JsRequest
impl RefMutFromWasmAbi for JsRequest
Source§impl TryFromJsValue for JsRequest
impl TryFromJsValue for JsRequest
Source§impl VectorFromWasmAbi for JsRequest
impl VectorFromWasmAbi for JsRequest
Source§impl VectorIntoWasmAbi for JsRequest
impl VectorIntoWasmAbi for JsRequest
impl SupportsConstructor for JsRequest
impl SupportsInstanceProperty for JsRequest
impl SupportsStaticProperty for JsRequest
Auto Trait Implementations§
impl Freeze for JsRequest
impl RefUnwindSafe for JsRequest
impl Send for JsRequest
impl Sync for JsRequest
impl Unpin for JsRequest
impl UnwindSafe for JsRequest
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> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::Abi
Source§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi
, except that it may throw and never
return in the case of Err
.