Enum gdnative::core_types::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
variant: String
Name of the unknown variant
expected: &'static [&'static str]
Names of all expected variants known at compile time
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
sourceimpl 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
sourceimpl Clone for FromVariantError
impl Clone for FromVariantError
sourcefn clone(&self) -> FromVariantError
fn clone(&self) -> FromVariantError
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for FromVariantError
impl Debug for FromVariantError
sourceimpl Display for FromVariantError
impl Display for FromVariantError
sourceimpl Error for FromVariantError
impl Error for FromVariantError
1.30.0 · sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · sourcefn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
sourceimpl PartialEq<FromVariantError> for FromVariantError
impl PartialEq<FromVariantError> for FromVariantError
sourcefn eq(&self, other: &FromVariantError) -> bool
fn eq(&self, other: &FromVariantError) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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<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,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.