Enum gdnative::prelude::FromVariantError
source · pub enum FromVariantError {
Show 13 variants
Unspecified,
Custom(String),
InvalidNil,
InvalidVariantType {
variant_type: VariantType,
expected: VariantType,
},
CannotCast {
class: String,
to: &'static str,
},
InvalidLength {
len: usize,
expected: usize,
},
InvalidEnumRepr {
expected: VariantEnumRepr,
error: Box<FromVariantError, Global>,
},
InvalidStructRepr {
expected: VariantStructRepr,
error: Box<FromVariantError, Global>,
},
UnknownEnumVariant {
variant: String,
expected: &'static [&'static str],
},
InvalidEnumVariant {
variant: &'static str,
error: Box<FromVariantError, Global>,
},
InvalidInstance {
expected: Cow<'static, str>,
},
InvalidField {
field_name: &'static str,
error: Box<FromVariantError, Global>,
},
InvalidItem {
index: usize,
error: Box<FromVariantError, Global>,
},
}
Expand description
Error type returned by FromVariant::from_variant
.
Variants§
Unspecified
An unspecified error.
Custom(String)
A custom error message.
InvalidNil
Null value given for a non-nullable type, with no further information given.
InvalidVariantType
Variant type is different from the expected one.
CannotCast
Cannot cast the object to the given Godot class.
InvalidLength
Length of the collection is different from the expected one.
InvalidEnumRepr
Invalid enum representation.
InvalidStructRepr
Invalid struct representation.
UnknownEnumVariant
Fields
Error indicating that the implementation encountered an enum variant that does not exist at compile time.
For example, trying to create a Result<T, E>
from { "Foo": "Bar" }
will result in this
error, since Foo
is not a valid variant of Result
.
InvalidEnumVariant
Error indicating that the implementation encountered a known enum variant, but the value is invalid for the definition.
This could result from multiple underlying reasons, detailed in the error
field:
- Missing fields.
- Unexpected representation, e.g.
{ "0": "foo", "1": "bar" }
for a tuple. - Error in a nested field.
InvalidInstance
Given object is not an instance of the expected NativeClass.
InvalidField
Collection contains an invalid field.
InvalidItem
Collection contains an invalid item.
Implementations§
source§impl FromVariantError
impl FromVariantError
sourcepub fn custom<T>(message: T) -> FromVariantErrorwhere
T: Display,
pub fn custom<T>(message: T) -> FromVariantErrorwhere
T: Display,
Returns a FromVariantError
with a custom message.
Trait Implementations§
source§impl Clone for FromVariantError
impl Clone for FromVariantError
source§fn clone(&self) -> FromVariantError
fn clone(&self) -> FromVariantError
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FromVariantError
impl Debug for FromVariantError
source§impl Display for FromVariantError
impl Display for FromVariantError
source§impl Error for FromVariantError
impl Error for FromVariantError
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 PartialEq<FromVariantError> for FromVariantError
impl PartialEq<FromVariantError> for FromVariantError
source§fn eq(&self, other: &FromVariantError) -> bool
fn eq(&self, other: &FromVariantError) -> bool
self
and other
values to be equal, and is used
by ==
.impl Eq for FromVariantError
impl StructuralEq for FromVariantError
impl StructuralPartialEq for FromVariantError
Auto Trait Implementations§
impl RefUnwindSafe for FromVariantError
impl Send for FromVariantError
impl Sync for FromVariantError
impl Unpin for FromVariantError
impl UnwindSafe for FromVariantError
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.