Trait FromGodot
pub trait FromGodot: Sized + GodotConvert {
// Required method
fn try_from_godot(via: Self::Via) -> Result<Self, ConvertError>;
// Provided methods
fn from_godot(via: Self::Via) -> Self { ... }
fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError> { ... }
fn from_variant(variant: &Variant) -> Self { ... }
}Expand description
Defines the canonical conversion from Godot for a type.
It is assumed that all the methods return equal values given equal inputs. Additionally, it is assumed
that if ToGodot is implemented, converting to Godot and back again will return a value equal to the
starting value.
Violating these assumptions is safe but will give unexpected results.
Please read the godot::meta module docs for further information about conversions.
This trait can be derived using the #[derive(GodotConvert)] macro.
Required Methods§
fn try_from_godot(via: Self::Via) -> Result<Self, ConvertError>
fn try_from_godot(via: Self::Via) -> Result<Self, ConvertError>
Converts the Godot representation to this type, returning Err on failure.
Provided Methods§
fn from_godot(via: Self::Via) -> Self
fn from_godot(via: Self::Via) -> Self
fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
Performs the conversion from a Variant, returning Err on failure.
fn from_variant(variant: &Variant) -> Self
fn from_variant(variant: &Variant) -> Self
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
§impl FromGodot for Result<(), Error>
Shim that can turn incoming Error values into Result<(), Error>s, where Error::OK becomes Ok(()).
impl FromGodot for Result<(), Error>
Shim that can turn incoming Error values into Result<(), Error>s, where Error::OK becomes Ok(()).