pub type NonExhaustiveWI<E, I> = NonExhaustive<E, <E as GetEnumInfo>::DefaultStorage, I>;
Expand description
The type of a NonExhaustive<>
wrapping the enum E,
using the E
’s default storage and a custom interface.
Aliased Type§
struct NonExhaustiveWI<E, I> { /* private fields */ }
Implementations
Source§impl<E, S, I> NonExhaustive<E, S, I>
impl<E, S, I> NonExhaustive<E, S, I>
Sourcepub const fn new(value: E) -> Selfwhere
E: GetVTable<S, I> + GetEnumInfo<DefaultStorage = S, DefaultInterface = I>,
pub const fn new(value: E) -> Selfwhere
E: GetVTable<S, I> + GetEnumInfo<DefaultStorage = S, DefaultInterface = I>,
Constructs a NonExhaustive<>
from value
using its default interface and storage.
§Panic
This panics if the storage has an alignment or size smaller than that of E
.
Sourcepub const fn with_interface(value: E) -> Selfwhere
E: GetVTable<S, I> + GetEnumInfo<DefaultStorage = S>,
pub const fn with_interface(value: E) -> Selfwhere
E: GetVTable<S, I> + GetEnumInfo<DefaultStorage = S>,
Constructs a NonExhaustive<>
from value
using its default storage
and a custom interface.
§Panic
This panics if the storage has an alignment or size smaller than that of E
.
Sourcepub const fn with_storage(value: E) -> Selfwhere
E: GetVTable<S, I> + GetEnumInfo<DefaultInterface = I>,
pub const fn with_storage(value: E) -> Selfwhere
E: GetVTable<S, I> + GetEnumInfo<DefaultInterface = I>,
Constructs a NonExhaustive<>
from value
using its default interface
and a custom storage.
§Panic
This panics if the storage has an alignment or size smaller than that of E
.
Sourcepub const fn with_storage_and_interface(value: E) -> Selfwhere
E: GetVTable<S, I>,
pub const fn with_storage_and_interface(value: E) -> Selfwhere
E: GetVTable<S, I>,
Constructs a NonExhaustive<>
from value
using both a custom interface and storage.
§Panic
This panics if the storage has an alignment or size smaller than that of E
.
Source§impl<E, S, I> NonExhaustive<E, S, I>where
E: GetEnumInfo,
impl<E, S, I> NonExhaustive<E, S, I>where
E: GetEnumInfo,
Sourcepub fn as_enum(&self) -> Result<&E, UnwrapEnumError<&Self>>
pub fn as_enum(&self) -> Result<&E, UnwrapEnumError<&Self>>
wraps a reference to this NonExhaustive<>
into a reference to the original enum.
§Errors
This returns an error if the wrapped enum is of a variant that is not valid in this context.
§Example
This shows how some NonExhaustive<enum>
can be unwrapped, and others cannot.
That enum comes from a newer version of the library than this knows.
use abi_stable::nonexhaustive_enum::doc_enums::example_2::{
new_a, new_b, new_c, Foo,
};
assert_eq!(new_a().as_enum().ok(), Some(&Foo::A));
assert_eq!(new_b(10).as_enum().ok(), Some(&Foo::B(10)));
assert_eq!(new_b(77).as_enum().ok(), Some(&Foo::B(77)));
assert_eq!(new_c().as_enum().ok(), None);
Sourcepub fn as_enum_mut(&mut self) -> Result<&mut E, UnwrapEnumError<&mut Self>>where
E: GetVTable<S, I>,
pub fn as_enum_mut(&mut self) -> Result<&mut E, UnwrapEnumError<&mut Self>>where
E: GetVTable<S, I>,
Unwraps a mutable reference to this NonExhaustive<>
into a
mutable reference to the original enum.
§Errors
This returns an error if the wrapped enum is of a variant that is not valid in this context.
§Example
This shows how some NonExhaustive<enum>
can be unwrapped, and others cannot.
That enum comes from a newer version of the library than this knows.
use abi_stable::nonexhaustive_enum::doc_enums::example_1::{
new_a, new_b, new_c, Foo,
};
assert_eq!(new_a().as_enum_mut().ok(), Some(&mut Foo::A));
assert_eq!(new_b(10).as_enum_mut().ok(), None);
assert_eq!(new_b(77).as_enum_mut().ok(), None);
assert_eq!(new_c().as_enum_mut().ok(), None);
Sourcepub fn into_enum(self) -> Result<E, UnwrapEnumError<Self>>
pub fn into_enum(self) -> Result<E, UnwrapEnumError<Self>>
Unwraps this NonExhaustive<>
into the original enum.
§Errors
This returns an error if the wrapped enum is of a variant that is not valid in this context.
§Example
This shows how some NonExhaustive<enum>
can be unwrapped, and others cannot.
That enum comes from a newer version of the library than this knows.
use abi_stable::nonexhaustive_enum::doc_enums::example_2::{
new_a, new_b, new_c, Foo,
};
assert_eq!(new_a().into_enum().ok(), Some(Foo::A));
assert_eq!(new_b(10).into_enum().ok(), Some(Foo::B(10)));
assert_eq!(new_b(77).into_enum().ok(), Some(Foo::B(77)));
assert_eq!(new_c().into_enum().ok(), None);
Sourcepub fn is_valid_discriminant(&self) -> bool
pub fn is_valid_discriminant(&self) -> bool
Returns whether the discriminant of this enum is valid in this context.
The only way for it to be invalid is if the dynamic library is a newer version than this knows.
Sourcepub const fn get_discriminant(&self) -> E::Discriminant
pub const fn get_discriminant(&self) -> E::Discriminant
Gets the value of the discriminant of the enum.
Source§impl<E, S, I> NonExhaustive<E, S, I>
impl<E, S, I> NonExhaustive<E, S, I>
Sourcepub const unsafe fn transmute_enum<F>(self) -> NonExhaustive<F, S, I>
pub const unsafe fn transmute_enum<F>(self) -> NonExhaustive<F, S, I>
Sourcepub const unsafe fn transmute_enum_ref<F>(&self) -> &NonExhaustive<F, S, I>
pub const unsafe fn transmute_enum_ref<F>(&self) -> &NonExhaustive<F, S, I>
Sourcepub unsafe fn transmute_enum_mut<F>(&mut self) -> &mut NonExhaustive<F, S, I>
pub unsafe fn transmute_enum_mut<F>(&mut self) -> &mut NonExhaustive<F, S, I>
Sourcepub unsafe fn transmute_enum_ptr<P, F>(this: P) -> P::TransmutedPtr
pub unsafe fn transmute_enum_ptr<P, F>(this: P) -> P::TransmutedPtr
Transmute this pointer to a NonExhaustive<E,S,I>
into
a pointer (of the same kind) to a NonExhaustive<F,S,I>
,
changing the type of the enum it wraps.
§Safety
This has the same safety requirements that
abi_stable::pointer_traits::TransmuteElement::transmute_element
has.
§Panics
This panics if the storage has an alignment or size smaller than that of F
.
Source§impl<E, S, I> NonExhaustive<E, S, I>where
E: GetEnumInfo,
impl<E, S, I> NonExhaustive<E, S, I>where
E: GetEnumInfo,
Sourcepub fn serialize_into_proxy(&self) -> Result<I::Proxy, RBoxError>
pub fn serialize_into_proxy(&self) -> Result<I::Proxy, RBoxError>
It serializes a NonExhaustive<_>
into a proxy.
Sourcepub fn deserialize_from_proxy<'borr>(proxy: I::Proxy) -> Result<Self, RBoxError>where
I: InterfaceType<Deserialize = Implemented<Deserialize>> + DeserializeEnum<'borr, Self>,
I::Proxy: 'borr,
pub fn deserialize_from_proxy<'borr>(proxy: I::Proxy) -> Result<Self, RBoxError>where
I: InterfaceType<Deserialize = Implemented<Deserialize>> + DeserializeEnum<'borr, Self>,
I::Proxy: 'borr,
Deserializes a NonExhaustive<_>
from a proxy.
Trait Implementations
Source§impl<E, S, I> Clone for NonExhaustive<E, S, I>
impl<E, S, I> Clone for NonExhaustive<E, S, I>
Source§impl<E, S, I> Debug for NonExhaustive<E, S, I>
impl<E, S, I> Debug for NonExhaustive<E, S, I>
Source§impl<'de, E, S, I> Deserialize<'de> for NonExhaustive<E, S, I>where
E: 'de + GetVTable<S, I>,
S: 'de,
I: 'de + InterfaceType<Deserialize = Implemented<Deserialize>> + DeserializeEnum<'de, Self>,
<I as DeserializeEnum<'de, Self>>::Proxy: Deserialize<'de>,
impl<'de, E, S, I> Deserialize<'de> for NonExhaustive<E, S, I>where
E: 'de + GetVTable<S, I>,
S: 'de,
I: 'de + InterfaceType<Deserialize = Implemented<Deserialize>> + DeserializeEnum<'de, Self>,
<I as DeserializeEnum<'de, Self>>::Proxy: Deserialize<'de>,
First it Deserializes a string,then it deserializes into a
NonExhaustive<_>
,by using <I as DeserializeEnum>::deserialize_enum
.
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>,
Source§impl<E, S, I> Display for NonExhaustive<E, S, I>
impl<E, S, I> Display for NonExhaustive<E, S, I>
Source§impl<E, S, I> Drop for NonExhaustive<E, S, I>
impl<E, S, I> Drop for NonExhaustive<E, S, I>
Source§impl<E, S, I> Error for NonExhaustive<E, S, I>where
I: InterfaceType<Debug = Implemented<Debug>, Display = Implemented<Display>, Error = Implemented<Error>>,
impl<E, S, I> Error for NonExhaustive<E, S, I>where
I: InterfaceType<Debug = Implemented<Debug>, Display = Implemented<Display>, Error = Implemented<Error>>,
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl<E, S, I> GetStaticEquivalent_ for NonExhaustive<E, S, I>where
E: __GetStaticEquivalent_ + NonExhaustiveMarker<S>,
S: __GetStaticEquivalent_,
I: __GetStaticEquivalent_ + InterfaceType,
NonExhaustiveVtable_Ref<E, S, I>: StableAbi,
impl<E, S, I> GetStaticEquivalent_ for NonExhaustive<E, S, I>where
E: __GetStaticEquivalent_ + NonExhaustiveMarker<S>,
S: __GetStaticEquivalent_,
I: __GetStaticEquivalent_ + InterfaceType,
NonExhaustiveVtable_Ref<E, S, I>: StableAbi,
Source§type StaticEquivalent = _static_NonExhaustive<<E as GetStaticEquivalent_>::StaticEquivalent, <S as GetStaticEquivalent_>::StaticEquivalent, <I as GetStaticEquivalent_>::StaticEquivalent>
type StaticEquivalent = _static_NonExhaustive<<E as GetStaticEquivalent_>::StaticEquivalent, <S as GetStaticEquivalent_>::StaticEquivalent, <I as GetStaticEquivalent_>::StaticEquivalent>
'static
equivalent of Self
Source§impl<E, S, I> Hash for NonExhaustive<E, S, I>
impl<E, S, I> Hash for NonExhaustive<E, S, I>
Source§type Discriminant = <E as GetEnumInfo>::Discriminant
type Discriminant = <E as GetEnumInfo>::Discriminant
Source§fn get_discriminant_(&self) -> E::Discriminant
fn get_discriminant_(&self) -> E::Discriminant
Source§fn enum_info_(&self) -> &'static EnumInfo
fn enum_info_(&self) -> &'static EnumInfo
Source§impl<E, S, I> Ord for NonExhaustive<E, S, I>
impl<E, S, I> Ord for NonExhaustive<E, S, I>
Source§impl<E, S, I> PartialEq<E> for NonExhaustive<E, S, I>
impl<E, S, I> PartialEq<E> for NonExhaustive<E, S, I>
Source§impl<E, S, I1, I2> PartialEq<NonExhaustive<E, S, I2>> for NonExhaustive<E, S, I1>
impl<E, S, I1, I2> PartialEq<NonExhaustive<E, S, I2>> for NonExhaustive<E, S, I1>
Source§impl<E, S, I> PartialOrd<E> for NonExhaustive<E, S, I>where
E: GetEnumInfo + PartialOrd,
I: InterfaceType<PartialOrd = Implemented<PartialOrd>>,
Self: PartialEq<E>,
impl<E, S, I> PartialOrd<E> for NonExhaustive<E, S, I>where
E: GetEnumInfo + PartialOrd,
I: InterfaceType<PartialOrd = Implemented<PartialOrd>>,
Self: PartialEq<E>,
Source§impl<E, S, I1, I2> PartialOrd<NonExhaustive<E, S, I2>> for NonExhaustive<E, S, I1>where
I1: InterfaceType<PartialOrd = Implemented<PartialOrd>>,
Self: PartialEq<NonExhaustive<E, S, I2>>,
impl<E, S, I1, I2> PartialOrd<NonExhaustive<E, S, I2>> for NonExhaustive<E, S, I1>where
I1: InterfaceType<PartialOrd = Implemented<PartialOrd>>,
Self: PartialEq<NonExhaustive<E, S, I2>>,
Source§impl<E, S, I> Serialize for NonExhaustive<E, S, I>
impl<E, S, I> Serialize for NonExhaustive<E, S, I>
First it serializes a NonExhaustive<_>
into a proxy,then it serializes that proxy.
Source§impl<E, S, I> StableAbi for NonExhaustive<E, S, I>where
E: __GetStaticEquivalent_ + NonExhaustiveMarker<S>,
S: __GetStaticEquivalent_,
I: __GetStaticEquivalent_ + InterfaceType,
NonExhaustiveVtable_Ref<E, S, I>: StableAbi,
<E as NonExhaustiveMarker<S>>::Marker: __StableAbi,
impl<E, S, I> StableAbi for NonExhaustive<E, S, I>where
E: __GetStaticEquivalent_ + NonExhaustiveMarker<S>,
S: __GetStaticEquivalent_,
I: __GetStaticEquivalent_ + InterfaceType,
NonExhaustiveVtable_Ref<E, S, I>: StableAbi,
<E as NonExhaustiveMarker<S>>::Marker: __StableAbi,
Source§const LAYOUT: &'static TypeLayout = _
const LAYOUT: &'static TypeLayout = _
Source§type IsNonZeroType = False
type IsNonZeroType = False
Source§const ABI_CONSTS: AbiConsts = _
const ABI_CONSTS: AbiConsts = _
const
-equivalents of the associated types.