pub struct JsResponse {
pub status_code: String,
pub headers: HashMap<String, String>,
pub body: Option<String>,
}
Expand description
Represents a response originating from Rust.
use crate::javascript_adapter::JsResponse;
#[wasm_bindgen]
pub fn app() -> JsResponse {
let mut response = JsResponse::new();
response.body = Some(String::from("hello world"));
response.headers.insert(String::from("Content-Type"), String::from("text/plain"));
response.status_code = String::from("200");
response
}
Fields§
§status_code: String
§headers: HashMap<String, String>
§body: Option<String>
Implementations§
Trait Implementations§
Source§impl From<JsResponse> for JsValue
impl From<JsResponse> for JsValue
Source§fn from(value: JsResponse) -> Self
fn from(value: JsResponse) -> Self
Converts to this type from the input type.
Source§impl FromWasmAbi for JsResponse
impl FromWasmAbi for JsResponse
Source§impl IntoWasmAbi for JsResponse
impl IntoWasmAbi for JsResponse
Source§impl LongRefFromWasmAbi for JsResponse
impl LongRefFromWasmAbi for JsResponse
Source§impl OptionFromWasmAbi for JsResponse
impl OptionFromWasmAbi for JsResponse
Source§impl OptionIntoWasmAbi for JsResponse
impl OptionIntoWasmAbi for JsResponse
Source§impl RefFromWasmAbi for JsResponse
impl RefFromWasmAbi for JsResponse
Source§type Anchor = RcRef<JsResponse>
type Anchor = RcRef<JsResponse>
The type that holds the reference to
Self
for the duration of the
invocation of the function that has an &Self
parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for JsResponse
impl RefMutFromWasmAbi for JsResponse
Source§impl TryFromJsValue for JsResponse
impl TryFromJsValue for JsResponse
Source§impl VectorFromWasmAbi for JsResponse
impl VectorFromWasmAbi for JsResponse
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[JsResponse]>
Source§impl VectorIntoJsValue for JsResponse
impl VectorIntoJsValue for JsResponse
fn vector_into_jsvalue(vector: Box<[JsResponse]>) -> JsValue
Source§impl VectorIntoWasmAbi for JsResponse
impl VectorIntoWasmAbi for JsResponse
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[JsResponse]>) -> Self::Abi
Source§impl WasmDescribeVector for JsResponse
impl WasmDescribeVector for JsResponse
impl SupportsConstructor for JsResponse
impl SupportsInstanceProperty for JsResponse
impl SupportsStaticProperty for JsResponse
Auto Trait Implementations§
impl Freeze for JsResponse
impl RefUnwindSafe for JsResponse
impl Send for JsResponse
impl Sync for JsResponse
impl Unpin for JsResponse
impl UnwindSafe for JsResponse
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
.