#[repr(transparent)]pub struct JsOption<T = JsValue> {
pub obj: JsValue,
pub generics: PhantomData<fn() -> T>,
}Fields§
§obj: JsValue§generics: PhantomData<fn() -> T>Implementations§
Source§impl<T: JsGeneric> JsOption<T>
impl<T: JsGeneric> JsOption<T>
pub fn new() -> Self
pub fn wrap(val: T) -> Self
pub fn from_option(opt: Option<T>) -> Self
pub fn is_empty(&self) -> bool
pub fn as_option(&self) -> Option<T>
pub fn into_option(self) -> Option<T>
pub fn unwrap(self) -> T
pub fn expect(self, msg: &str) -> T
pub fn unwrap_or_default(self) -> Twhere
T: Default,
pub fn unwrap_or_else<F>(self, f: F) -> Twhere
F: FnOnce() -> T,
Trait Implementations§
Source§impl<T> BatchableResult for JsOption<T>
impl<T> BatchableResult for JsOption<T>
Source§impl<T> BinaryDecode for JsOption<T>
impl<T> BinaryDecode for JsOption<T>
fn decode(decoder: &mut DecodedData<'_>) -> Result<Self, DecodeError>
Source§impl<T> BinaryEncode for JsOption<T>
impl<T> BinaryEncode for JsOption<T>
fn encode(self, encoder: &mut EncodedData)
Source§impl<T> EncodeTypeDef for JsOption<T>
impl<T> EncodeTypeDef for JsOption<T>
Source§fn encode_type_def(buf: &mut Vec<u8>)
fn encode_type_def(buf: &mut Vec<u8>)
Encode this type’s definition into the buffer.
For primitives, this is just the TypeTag byte.
For callbacks, this includes param count, param types, and return type.
Source§impl<T: JsGeneric> IntoJsGeneric for JsOption<T>
impl<T: JsGeneric> IntoJsGeneric for JsOption<T>
Source§impl<T: JsGeneric> JsCast for JsOption<T>
impl<T: JsGeneric> JsCast for JsOption<T>
Source§fn instanceof(value: &JsValue) -> bool
fn instanceof(value: &JsValue) -> bool
Check if a JsValue is an instance of this type. Read more
Source§fn unchecked_from_js(value: JsValue) -> Self
fn unchecked_from_js(value: JsValue) -> Self
Unchecked cast from JsValue to this type. Read more
Source§fn unchecked_from_js_ref(value: &JsValue) -> &Self
fn unchecked_from_js_ref(value: &JsValue) -> &Self
Unchecked cast from a JsValue reference to a reference of this type. Read more
Source§fn is_type_of(val: &JsValue) -> bool
fn is_type_of(val: &JsValue) -> bool
Performs a dynamic type check to see whether the
JsValue provided
is a value of this type. Read moreSource§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,
Try to cast this value to type T. Read more
Source§fn dyn_ref<T>(&self) -> Option<&T>where
T: JsCast,
fn dyn_ref<T>(&self) -> Option<&T>where
T: JsCast,
Try to get a reference to type T from this value. Read more
Source§fn is_instance_of<T>(&self) -> boolwhere
T: JsCast,
fn is_instance_of<T>(&self) -> boolwhere
T: JsCast,
Test whether this JS value is an instance of the type
T. Read moreSource§fn unchecked_into<T>(self) -> Twhere
T: JsCast,
fn unchecked_into<T>(self) -> Twhere
T: JsCast,
Unchecked cast to another type.
Source§fn unchecked_ref<T>(&self) -> &Twhere
T: JsCast,
fn unchecked_ref<T>(&self) -> &Twhere
T: JsCast,
Unchecked cast to a reference of another type.
Source§impl<T: PartialEq> PartialEq for JsOption<T>
impl<T: PartialEq> PartialEq for JsOption<T>
impl<T> StructuralPartialEq for JsOption<T>
impl<T> UpcastFrom<()> for JsOption<T>
impl<T1, Target1> UpcastFrom<(T1,)> for JsOption<(Target1,)>
impl<T1, T2, Target1, Target2> UpcastFrom<(T1, T2)> for JsOption<(Target1, Target2)>where
T1: JsGeneric,
T2: JsGeneric,
Target1: JsGeneric + UpcastFrom<T1>,
Target2: JsGeneric + UpcastFrom<T2>,
impl<T1, T2, T3, Target1, Target2, Target3> UpcastFrom<(T1, T2, T3)> for JsOption<(Target1, Target2, Target3)>where
T1: JsGeneric,
T2: JsGeneric,
T3: JsGeneric,
Target1: JsGeneric + UpcastFrom<T1>,
Target2: JsGeneric + UpcastFrom<T2>,
Target3: JsGeneric + UpcastFrom<T3>,
impl<T1, T2, T3, T4, Target1, Target2, Target3, Target4> UpcastFrom<(T1, T2, T3, T4)> for JsOption<(Target1, Target2, Target3, Target4)>where
T1: JsGeneric,
T2: JsGeneric,
T3: JsGeneric,
T4: JsGeneric,
Target1: JsGeneric + UpcastFrom<T1>,
Target2: JsGeneric + UpcastFrom<T2>,
Target3: JsGeneric + UpcastFrom<T3>,
Target4: JsGeneric + UpcastFrom<T4>,
impl<T1, T2, T3, T4, T5, Target1, Target2, Target3, Target4, Target5> UpcastFrom<(T1, T2, T3, T4, T5)> for JsOption<(Target1, Target2, Target3, Target4, Target5)>where
T1: JsGeneric,
T2: JsGeneric,
T3: JsGeneric,
T4: JsGeneric,
T5: JsGeneric,
Target1: JsGeneric + UpcastFrom<T1>,
Target2: JsGeneric + UpcastFrom<T2>,
Target3: JsGeneric + UpcastFrom<T3>,
Target4: JsGeneric + UpcastFrom<T4>,
Target5: JsGeneric + UpcastFrom<T5>,
impl<T1, T2, T3, T4, T5, T6, Target1, Target2, Target3, Target4, Target5, Target6> UpcastFrom<(T1, T2, T3, T4, T5, T6)> for JsOption<(Target1, Target2, Target3, Target4, Target5, Target6)>where
T1: JsGeneric,
T2: JsGeneric,
T3: JsGeneric,
T4: JsGeneric,
T5: JsGeneric,
T6: JsGeneric,
Target1: JsGeneric + UpcastFrom<T1>,
Target2: JsGeneric + UpcastFrom<T2>,
Target3: JsGeneric + UpcastFrom<T3>,
Target4: JsGeneric + UpcastFrom<T4>,
Target5: JsGeneric + UpcastFrom<T5>,
Target6: JsGeneric + UpcastFrom<T6>,
impl<T1, T2, T3, T4, T5, T6, T7, Target1, Target2, Target3, Target4, Target5, Target6, Target7> UpcastFrom<(T1, T2, T3, T4, T5, T6, T7)> for JsOption<(Target1, Target2, Target3, Target4, Target5, Target6, Target7)>where
T1: JsGeneric,
T2: JsGeneric,
T3: JsGeneric,
T4: JsGeneric,
T5: JsGeneric,
T6: JsGeneric,
T7: JsGeneric,
Target1: JsGeneric + UpcastFrom<T1>,
Target2: JsGeneric + UpcastFrom<T2>,
Target3: JsGeneric + UpcastFrom<T3>,
Target4: JsGeneric + UpcastFrom<T4>,
Target5: JsGeneric + UpcastFrom<T5>,
Target6: JsGeneric + UpcastFrom<T6>,
Target7: JsGeneric + UpcastFrom<T7>,
impl<T1, T2, T3, T4, T5, T6, T7, T8, Target1, Target2, Target3, Target4, Target5, Target6, Target7, Target8> UpcastFrom<(T1, T2, T3, T4, T5, T6, T7, T8)> for JsOption<(Target1, Target2, Target3, Target4, Target5, Target6, Target7, Target8)>where
T1: JsGeneric,
T2: JsGeneric,
T3: JsGeneric,
T4: JsGeneric,
T5: JsGeneric,
T6: JsGeneric,
T7: JsGeneric,
T8: JsGeneric,
Target1: JsGeneric + UpcastFrom<T1>,
Target2: JsGeneric + UpcastFrom<T2>,
Target3: JsGeneric + UpcastFrom<T3>,
Target4: JsGeneric + UpcastFrom<T4>,
Target5: JsGeneric + UpcastFrom<T5>,
Target6: JsGeneric + UpcastFrom<T6>,
Target7: JsGeneric + UpcastFrom<T7>,
Target8: JsGeneric + UpcastFrom<T8>,
impl<T> UpcastFrom<JsOption<T>> for JsValue
impl<T, U> UpcastFrom<JsOption<U>> for JsOption<T>where
T: UpcastFrom<U>,
impl UpcastFrom<JsValue> for JsOption<JsValue>
impl<T> UpcastFrom<Null> for JsOption<T>
impl<T> UpcastFrom<Undefined> for JsOption<T>
Auto Trait Implementations§
impl<T> Freeze for JsOption<T>
impl<T> RefUnwindSafe for JsOption<T>
impl<T> Send for JsOption<T>
impl<T> Sync for JsOption<T>
impl<T> Unpin for JsOption<T>
impl<T> UnsafeUnpin for JsOption<T>
impl<T> UnwindSafe for JsOption<T>
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> FromWasmAbi for Twhere
T: BinaryDecode + EncodeTypeDef,
impl<T> FromWasmAbi for Twhere
T: BinaryDecode + EncodeTypeDef,
Source§impl<T> IntoWasmAbi for Twhere
T: BinaryEncode + EncodeTypeDef,
impl<T> IntoWasmAbi for Twhere
T: BinaryEncode + EncodeTypeDef,
Source§impl<T> RefFromBinaryDecode for Twhere
T: JsCast + 'static,
impl<T> RefFromBinaryDecode for Twhere
T: JsCast + 'static,
Source§type Anchor = JsCastAnchor<T>
type Anchor = JsCastAnchor<T>
The anchor type that keeps the decoded reference valid.
Source§fn ref_decode(
_decoder: &mut DecodedData<'_>,
) -> Result<<T as RefFromBinaryDecode>::Anchor, DecodeError>
fn ref_decode( _decoder: &mut DecodedData<'_>, ) -> Result<<T as RefFromBinaryDecode>::Anchor, DecodeError>
Decode a reference anchor from binary data.