Struct rora_javascript_adapter::JsResponse
source · [−]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
sourceimpl JsResponse
impl JsResponse
Trait Implementations
sourceimpl From<JsResponse> for JsValue
impl From<JsResponse> for JsValue
sourcefn from(value: JsResponse) -> Self
fn from(value: JsResponse) -> Self
Converts to this type from the input type.
sourceimpl FromWasmAbi for JsResponse
impl FromWasmAbi for JsResponse
sourceimpl IntoWasmAbi for JsResponse
impl IntoWasmAbi for JsResponse
sourceimpl OptionFromWasmAbi for JsResponse
impl OptionFromWasmAbi for JsResponse
sourceimpl OptionIntoWasmAbi for JsResponse
impl OptionIntoWasmAbi for JsResponse
sourceimpl RefFromWasmAbi for JsResponse
impl RefFromWasmAbi for JsResponse
type Anchor = Ref<'static, JsResponse>
type Anchor = Ref<'static, 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. Read more
sourceunsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor
Recover a Self::Anchor
from Self::Abi
. Read more
sourceimpl RefMutFromWasmAbi for JsResponse
impl RefMutFromWasmAbi for JsResponse
type Anchor = RefMut<'static, JsResponse>
type Anchor = RefMut<'static, JsResponse>
Same as RefFromWasmAbi::Anchor
sourceunsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
Same as RefFromWasmAbi::ref_from_abi
sourceimpl WasmDescribe for JsResponse
impl WasmDescribe for JsResponse
Auto Trait Implementations
impl RefUnwindSafe for JsResponse
impl Send for JsResponse
impl Sync for JsResponse
impl Unpin for JsResponse
impl UnwindSafe for JsResponse
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ReturnWasmAbi for T where
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for T where
T: IntoWasmAbi,
type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as IntoWasmAbi::Abi
sourcefn 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
. Read more