pub trait ReflectRemote: Reflect {
type Remote;
// Required methods
fn as_remote(&self) -> &Self::Remote;
fn as_remote_mut(&mut self) -> &mut Self::Remote;
fn into_remote(self) -> Self::Remote;
fn as_wrapper(remote: &Self::Remote) -> &Self;
fn as_wrapper_mut(remote: &mut Self::Remote) -> &mut Self;
fn into_wrapper(remote: Self::Remote) -> Self;
}Expand description
Marks a type as a reflectable wrapper for a remote type.
This allows types from external libraries (remote types) to be included in reflection.
The #[reflect_remote] attribute macro generates a
#[repr(transparent)] wrapper and an implementation of this trait. Its conversion methods
use the wrapper’s transparent representation.
Manual implementations may use different representation and conversion behavior. The
associated Remote type identifies the remote type represented by this wrapper.
§Example
use bevy_reflect_derive::{reflect_remote, Reflect};
mod some_lib {
pub struct TheirType {
pub value: u32
}
}
#[reflect_remote(some_lib::TheirType)]
struct MyType {
pub value: u32
}
#[derive(Reflect)]
struct MyStruct {
#[reflect(remote = MyType)]
data: some_lib::TheirType,
}Required Associated Types§
Required Methods§
Sourcefn as_remote(&self) -> &Self::Remote
fn as_remote(&self) -> &Self::Remote
Converts a reference of this wrapper to a reference of its remote type.
Sourcefn as_remote_mut(&mut self) -> &mut Self::Remote
fn as_remote_mut(&mut self) -> &mut Self::Remote
Converts a mutable reference of this wrapper to a mutable reference of its remote type.
Sourcefn into_remote(self) -> Self::Remote
fn into_remote(self) -> Self::Remote
Converts this wrapper into its remote type.
Sourcefn as_wrapper(remote: &Self::Remote) -> &Self
fn as_wrapper(remote: &Self::Remote) -> &Self
Converts a reference of the remote type to a reference of this wrapper.
Sourcefn as_wrapper_mut(remote: &mut Self::Remote) -> &mut Self
fn as_wrapper_mut(remote: &mut Self::Remote) -> &mut Self
Converts a mutable reference of the remote type to a mutable reference of this wrapper.
Sourcefn into_wrapper(remote: Self::Remote) -> Self
fn into_wrapper(remote: Self::Remote) -> Self
Converts the remote type into this wrapper.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".