godot::meta

Struct RefArg

pub struct RefArg<'r, T> { /* private fields */ }
Expand description

Simple reference wrapper, used when passing arguments by-ref to Godot APIs.

This type is often used as the result of ToGodot::to_godot(), if Self is not a Copy type.

Implementations§

§

impl<'r, T> RefArg<'r, T>

pub fn new(shared_ref: &'r T) -> RefArg<'r, T>

Creates a new RefArg from a reference.

Unless you implement your own ToGodot impl, there is usually no reason to use this.

pub fn get_ref(&self) -> &T

Returns the stored reference.

§Panics

If T is Option<Gd<...>>::None.

pub fn get_ref_or_none(&self) -> Option<&T>
where T: GodotNullableFfi,

Returns the stored reference.

Returns None if T is Option<Gd<...>>::None.

pub fn to_owned(&self) -> T
where T: Clone,

Returns the stored reference.

§Panics

If T is Option<Gd<...>>::None.

Trait Implementations§

§

impl<'r, T> Debug for RefArg<'r, T>
where T: Debug,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<'r, T> FromGodot for RefArg<'r, T>
where T: FromGodot,

§

fn try_from_godot( _via: <RefArg<'r, T> as GodotConvert>::Via, ) -> Result<RefArg<'r, T>, ConvertError>

Converts the Godot representation to this type, returning Err on failure.
§

fn from_godot(via: Self::Via) -> Self

⚠️ Converts the Godot representation to this type. Read more
§

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

⚠️ Performs the conversion from a Variant. Read more
§

impl<'r, T> GodotConvert for RefArg<'r, T>
where T: GodotConvert,

§

type Via = <T as GodotConvert>::Via

The type through which Self is represented in Godot.
§

impl<'r, T> GodotNullableFfi for RefArg<'r, T>
where T: GodotNullableFfi,

§

fn null() -> RefArg<'r, T>

§

fn is_null(&self) -> bool

§

fn flatten_option(opt: Option<Self>) -> Self

§

impl<'r, T> ToGodot for RefArg<'r, T>
where T: ToGodot,

§

type ToVia<'v> = <T as ToGodot>::ToVia<'v> where RefArg<'r, T>: 'v

Target type of to_godot(), which can differ from Via for pass-by-reference types. Read more
§

fn to_godot(&self) -> <RefArg<'r, T> as ToGodot>::ToVia<'_>

Converts this type to the Godot type by reference, usually by cloning.
§

fn to_variant(&self) -> Variant

Converts this type to a Variant.

Auto Trait Implementations§

§

impl<'r, T> Freeze for RefArg<'r, T>

§

impl<'r, T> RefUnwindSafe for RefArg<'r, T>
where T: RefUnwindSafe,

§

impl<'r, T> Send for RefArg<'r, T>
where T: Sync,

§

impl<'r, T> Sync for RefArg<'r, T>
where T: Sync,

§

impl<'r, T> Unpin for RefArg<'r, T>

§

impl<'r, T> UnwindSafe for RefArg<'r, T>
where T: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.