pub struct Handle<T> { /* private fields */ }Expand description
Handle is some sort of non-owning reference to content in a pool. It stores index of object and additional information that allows to ensure that handle is still valid (points to the same object as when handle was created).
Implementations§
Source§impl<T> Handle<T>
impl<T> Handle<T>
pub const NONE: Handle<T>
Sourcepub fn to_base<B>(self) -> Handle<B>where
T: ObjectOrVariant<B>,
pub fn to_base<B>(self) -> Handle<B>where
T: ObjectOrVariant<B>,
Converts the handle to its base variant. In other words, if there are two related types and
A is a variant of B, then this method converts Handle<A> -> Handle<B>.
Sourcepub fn to_variant<V>(self) -> Handle<V>where
V: ObjectOrVariant<T>,
pub fn to_variant<V>(self) -> Handle<V>where
V: ObjectOrVariant<T>,
Converts the handle of a base object to the handle of its variant.
pub fn is_none(self) -> bool
pub fn is_some(self) -> bool
pub fn index(self) -> u32
pub fn generation(self) -> u32
pub fn new(index: u32, generation: u32) -> Self
pub fn transmute<U>(&self) -> Handle<U>
pub fn decode_from_u128(num: u128) -> Self
pub fn encode_to_u128(&self) -> u128
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Handle<T>
impl<'de, T> Deserialize<'de> for Handle<T>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> From<AtomicHandle> for Handle<T>
impl<T> From<AtomicHandle> for Handle<T>
Source§fn from(atomic_handle: AtomicHandle) -> Self
fn from(atomic_handle: AtomicHandle) -> Self
Converts to this type from the input type.
Source§impl<T> From<ErasedHandle> for Handle<T>
impl<T> From<ErasedHandle> for Handle<T>
Source§fn from(erased_handle: ErasedHandle) -> Self
fn from(erased_handle: ErasedHandle) -> Self
Converts to this type from the input type.
Source§impl<T> From<Handle<T>> for ErasedHandle
impl<T> From<Handle<T>> for ErasedHandle
Source§impl<T, U, Container> Index<Handle<U>> for Pool<T, Container>where
T: 'static,
U: ObjectOrVariant<T>,
Container: PayloadContainer<Element = T> + 'static,
impl<T, U, Container> Index<Handle<U>> for Pool<T, Container>where
T: 'static,
U: ObjectOrVariant<T>,
Container: PayloadContainer<Element = T> + 'static,
Source§impl<T, U, Container> IndexMut<Handle<U>> for Pool<T, Container>where
T: 'static,
U: ObjectOrVariant<T>,
Container: PayloadContainer<Element = T> + 'static,
impl<T, U, Container> IndexMut<Handle<U>> for Pool<T, Container>where
T: 'static,
U: ObjectOrVariant<T>,
Container: PayloadContainer<Element = T> + 'static,
Source§impl<T> Ord for Handle<T>
impl<T> Ord for Handle<T>
Source§impl<T> PartialOrd for Handle<T>
impl<T> PartialOrd for Handle<T>
Source§impl<T: Reflect> Reflect for Handle<T>
impl<T: Reflect> Reflect for Handle<T>
fn source_path() -> &'static str
fn derived_types() -> &'static [TypeId]where
Self: Sized,
fn try_clone_box(&self) -> Option<Box<dyn Reflect>>
fn query_derived_types(&self) -> &'static [TypeId]
fn type_name(&self) -> &'static str
fn doc(&self) -> &'static str
Source§fn assembly_name(&self) -> &'static str
fn assembly_name(&self) -> &'static str
Returns a parent assembly name of the type that implements this trait. WARNING: You should use
proc-macro (
#[derive(Reflect)]) to ensure that this method will return correct assembly
name. In other words - there’s no guarantee, that any implementation other than proc-macro
will return a correct name of the assembly. Alternatively, you can use env!("CARGO_PKG_NAME")
as an implementation.Source§fn type_assembly_name() -> &'static str
fn type_assembly_name() -> &'static str
Returns a parent assembly name of the type that implements this trait. WARNING: You should use
proc-macro (
#[derive(Reflect)]) to ensure that this method will return correct assembly
name. In other words - there’s no guarantee, that any implementation other than proc-macro
will return a correct name of the assembly. Alternatively, you can use env!("CARGO_PKG_NAME")
as an implementation.fn fields_ref(&self, func: &mut dyn FnMut(&[FieldRef<'_, '_>]))
fn fields_mut(&mut self, func: &mut dyn FnMut(&mut [FieldMut<'_, '_>]))
fn into_any(self: Box<Self>) -> Box<dyn Any>
fn as_any(&self, func: &mut dyn FnMut(&dyn Any))
fn as_any_mut(&mut self, func: &mut dyn FnMut(&mut dyn Any))
fn as_reflect(&self, func: &mut dyn FnMut(&dyn Reflect))
fn as_reflect_mut(&mut self, func: &mut dyn FnMut(&mut dyn Reflect))
fn set( &mut self, value: Box<dyn Reflect>, ) -> Result<Box<dyn Reflect>, Box<dyn Reflect>>
fn as_handle(&self, func: &mut dyn FnMut(Option<&dyn ReflectHandle>))
fn as_handle_mut( &mut self, func: &mut dyn FnMut(Option<&mut dyn ReflectHandle>), )
Source§fn set_field(
&mut self,
field_name: &str,
value: Box<dyn Reflect>,
func: &mut dyn FnMut(Result<Box<dyn Reflect>, SetFieldError>),
)
fn set_field( &mut self, field_name: &str, value: Box<dyn Reflect>, func: &mut dyn FnMut(Result<Box<dyn Reflect>, SetFieldError>), )
Calls user method specified with
#[reflect(setter = ..)] or falls back to
Reflect::field_mutfn field(&self, name: &str, func: &mut dyn FnMut(Option<&dyn Reflect>))
fn field_mut( &mut self, name: &str, func: &mut dyn FnMut(Option<&mut dyn Reflect>), )
fn as_array(&self, func: &mut dyn FnMut(Option<&dyn ReflectArray>))
fn as_array_mut(&mut self, func: &mut dyn FnMut(Option<&mut dyn ReflectArray>))
fn as_list(&self, func: &mut dyn FnMut(Option<&dyn ReflectList>))
fn as_list_mut(&mut self, func: &mut dyn FnMut(Option<&mut dyn ReflectList>))
fn as_inheritable_variable( &self, func: &mut dyn FnMut(Option<&dyn ReflectInheritableVariable>), )
fn as_inheritable_variable_mut( &mut self, func: &mut dyn FnMut(Option<&mut dyn ReflectInheritableVariable>), )
fn as_hash_map(&self, func: &mut dyn FnMut(Option<&dyn ReflectHashMap>))
fn as_hash_map_mut( &mut self, func: &mut dyn FnMut(Option<&mut dyn ReflectHashMap>), )
Source§impl<T: Reflect> ReflectHandle for Handle<T>
impl<T: Reflect> ReflectHandle for Handle<T>
fn reflect_inner_type_id(&self) -> TypeId
fn reflect_inner_type_name(&self) -> &'static str
fn reflect_is_some(&self) -> bool
fn reflect_set_index(&mut self, index: u32)
fn reflect_index(&self) -> u32
fn reflect_set_generation(&mut self, generation: u32)
fn reflect_generation(&self) -> u32
fn reflect_as_erased(&self) -> ErasedHandle
Source§impl<T> TypeUuidProvider for Handle<T>where
T: TypeUuidProvider,
impl<T> TypeUuidProvider for Handle<T>where
T: TypeUuidProvider,
Source§impl<T> Visit for Handle<T>
impl<T> Visit for Handle<T>
Source§fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult
fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult
Read or write this value, depending on whether Visitor::is_reading() is true or false. Read more
impl<T> Copy for Handle<T>
impl<T> Eq for Handle<T>
impl<T> Send for Handle<T>
impl<T> Sync for Handle<T>
Auto Trait Implementations§
impl<T> Freeze for Handle<T>
impl<T> RefUnwindSafe for Handle<T>where
T: RefUnwindSafe,
impl<T> Unpin for Handle<T>where
T: Unpin,
impl<T> UnsafeUnpin for Handle<T>
impl<T> UnwindSafe for Handle<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> AsyncTaskResult for T
impl<T> AsyncTaskResult for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FieldValue for Twhere
T: Reflect,
impl<T> FieldValue for Twhere
T: Reflect,
Source§fn field_value_as_any_ref(&self) -> &(dyn Any + 'static)
fn field_value_as_any_ref(&self) -> &(dyn Any + 'static)
Casts
self to a &dyn AnySource§fn field_value_as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn field_value_as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Casts
self to a &mut dyn Anyfn field_value_as_reflect(&self) -> &(dyn Reflect + 'static)
fn field_value_as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
fn type_name(&self) -> &'static str
Source§impl<T, U> ObjectOrVariant<T> for Uwhere
PhantomData<U>: ObjectOrVariantHelper<T, U>,
impl<T, U> ObjectOrVariant<T> for Uwhere
PhantomData<U>: ObjectOrVariantHelper<T, U>,
Source§impl<T> ReflectBase for Twhere
T: Reflect,
impl<T> ReflectBase for Twhere
T: Reflect,
fn as_any_raw(&self) -> &(dyn Any + 'static)
fn as_any_raw_mut(&mut self) -> &mut (dyn Any + 'static)
Source§impl<T> ResolvePath for Twhere
T: Reflect,
impl<T> ResolvePath for Twhere
T: Reflect,
fn resolve_path<'p>( &self, path: &'p str, func: &mut dyn FnMut(Result<&(dyn Reflect + 'static), ReflectPathError<'p>>), )
fn resolve_path_mut<'p>( &mut self, path: &'p str, func: &mut dyn FnMut(Result<&mut (dyn Reflect + 'static), ReflectPathError<'p>>), )
fn get_resolve_path<'p, T: Reflect>( &self, path: &'p str, func: &mut dyn FnMut(Result<&T, ReflectPathError<'p>>), )
fn get_resolve_path_mut<'p, T: Reflect>( &mut self, path: &'p str, func: &mut dyn FnMut(Result<&mut T, ReflectPathError<'p>>), )
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.