pub enum WasmEncodedResult<T> {
Success {
value: T,
error: Option<WasmEncodedError>,
},
Err {
value: Option<T>,
error: WasmEncodedError,
},
}Expand description
A generic result enum that holds info of a rust Result that is serializable natively to JS/TS through wasm bindgen, so binding functions can return it normally in JS/TS instead of throwing.
Used in [wasm_bindgen_utils_macros::wasm_export!] as the returning type of exporting wasm binding functions.
Variants§
Success
Success variant that contains an instance of T in
valuefield with a Option::None error field
Err
Error variant that contains an instance of WasmEncodedError
in error field with a Option::None value field
Implementations§
Source§impl<T> WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
impl<T> WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
Sourcepub fn try_into_js_value(&self) -> Result<JsValue, Error>
pub fn try_into_js_value(&self) -> Result<JsValue, Error>
A simple helpful wrapper for serde_wasm_bindgen::to_value as self method for easy accessible conversion
Sourcepub fn try_from_js_value(js: JsValue) -> Result<Self, Error>
pub fn try_from_js_value(js: JsValue) -> Result<Self, Error>
A simple helpful wrapper for serde_wasm_bindgen::from_value as Self method for easy accessible conversion
Source§impl<T> WasmEncodedResult<T>
impl<T> WasmEncodedResult<T>
Trait Implementations§
Source§impl<T: Clone> Clone for WasmEncodedResult<T>
impl<T: Clone> Clone for WasmEncodedResult<T>
Source§fn clone(&self) -> WasmEncodedResult<T>
fn clone(&self) -> WasmEncodedResult<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for WasmEncodedResult<T>
impl<T: Debug> Debug for WasmEncodedResult<T>
Source§impl<'de, T> Deserialize<'de> for WasmEncodedResult<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for WasmEncodedResult<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T, E: Into<WasmEncodedError>> From<Result<T, E>> for WasmEncodedResult<T>
impl<T, E: Into<WasmEncodedError>> From<Result<T, E>> for WasmEncodedResult<T>
Source§impl<T> From<WasmEncodedResult<T>> for JsValuewhere
T: Serialize + for<'de> Deserialize<'de>,
impl<T> From<WasmEncodedResult<T>> for JsValuewhere
T: Serialize + for<'de> Deserialize<'de>,
Source§fn from(value: WasmEncodedResult<T>) -> Self
fn from(value: WasmEncodedResult<T>) -> Self
Converts to this type from the input type.
Source§impl<T> FromWasmAbi for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
impl<T> FromWasmAbi for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
Source§impl<T> IntoWasmAbi for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
impl<T> IntoWasmAbi for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
Source§impl<T> LongRefFromWasmAbi for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
impl<T> LongRefFromWasmAbi for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
Source§type Abi = <<WasmEncodedResult<T> as Tsify>::JsType as LongRefFromWasmAbi>::Abi
type Abi = <<WasmEncodedResult<T> as Tsify>::JsType as LongRefFromWasmAbi>::Abi
Same as
RefFromWasmAbi::AbiSource§type Anchor = Box<WasmEncodedResult<T>>
type Anchor = Box<WasmEncodedResult<T>>
Same as
RefFromWasmAbi::AnchorSource§unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
Same as
RefFromWasmAbi::ref_from_abiSource§impl<T> OptionFromWasmAbi for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
impl<T> OptionFromWasmAbi for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
Source§impl<T> OptionIntoWasmAbi for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
impl<T> OptionIntoWasmAbi for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
Source§impl<T: PartialEq> PartialEq for WasmEncodedResult<T>
impl<T: PartialEq> PartialEq for WasmEncodedResult<T>
Source§impl<T> RefFromWasmAbi for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
impl<T> RefFromWasmAbi for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
Source§type Abi = <<WasmEncodedResult<T> as Tsify>::JsType as RefFromWasmAbi>::Abi
type Abi = <<WasmEncodedResult<T> as Tsify>::JsType as RefFromWasmAbi>::Abi
The Wasm ABI type references to
Self are recovered from.Source§type Anchor = Box<WasmEncodedResult<T>>
type Anchor = Box<WasmEncodedResult<T>>
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<T> Serialize for WasmEncodedResult<T>where
T: Serialize,
impl<T> Serialize for WasmEncodedResult<T>where
T: Serialize,
Source§impl<T> TryFromJsValue for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
impl<T> TryFromJsValue for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
Source§impl<T> Tsify for WasmEncodedResult<T>
impl<T> Tsify for WasmEncodedResult<T>
const DECL: &'static str = "export type WasmEncodedResult<T> = { value: T; error: undefined } | { value: undefined; error: WasmEncodedError };"
type JsType = JsType
fn into_js(&self) -> Result<Self::JsType, Error>where
Self: Serialize,
fn from_js<T>(js: T) -> Result<Self, Error>
Source§impl<T> VectorFromWasmAbi for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
impl<T> VectorFromWasmAbi for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
type Abi = <Box<[<WasmEncodedResult<T> as Tsify>::JsType]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[Self]>
Source§impl<T> VectorIntoJsValue for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
impl<T> VectorIntoJsValue for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
fn vector_into_jsvalue(vector: Box<[Self]>) -> JsValue
Source§impl<T> VectorIntoWasmAbi for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
impl<T> VectorIntoWasmAbi for WasmEncodedResult<T>where
T: Serialize + for<'de> Deserialize<'de>,
type Abi = <Box<[<WasmEncodedResult<T> as Tsify>::JsType]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[Self]>) -> Self::Abi
Source§impl<T> WasmDescribeVector for WasmEncodedResult<T>
impl<T> WasmDescribeVector for WasmEncodedResult<T>
impl<T> StructuralPartialEq for WasmEncodedResult<T>
Auto Trait Implementations§
impl<T> Freeze for WasmEncodedResult<T>where
T: Freeze,
impl<T> RefUnwindSafe for WasmEncodedResult<T>where
T: RefUnwindSafe,
impl<T> Send for WasmEncodedResult<T>where
T: Send,
impl<T> Sync for WasmEncodedResult<T>where
T: Sync,
impl<T> Unpin for WasmEncodedResult<T>where
T: Unpin,
impl<T> UnwindSafe for WasmEncodedResult<T>where
T: UnwindSafe,
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> 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::AbiSource§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.