[][src]Struct handy::typed::TypedHandle

#[repr(transparent)]pub struct TypedHandle<T> { /* fields omitted */ }

A TypedHandle is a wrapper around a Handle which gives you some additional type safety, should you desire. You use it with a TypedHandleMap, which only will accept handles of the correct type. This could be useful if you have several handle maps in your program, and find

TypedHandle<T> is Copy + Send + Sync (and several others) regardless of T, which is not true for a naïve implementation of this, so it's provided even though I don't think it's that helpful for most usage (handle maps already detect this at runtime).

Implementations

impl<T> TypedHandle<T>[src]

pub const EMPTY: Self[src]

The TypedHandle equivalent of Handle::EMPTY.

pub const fn from_handle(h: Handle) -> Self[src]

Construct a typed handle from an untyped Handle.

This typically shouldn't be necessary if you're using typed maps exclusively, but could be useful when building abstractions on top of handles.

pub const fn handle(self) -> Handle[src]

Access the wrapped untyped handle.

This typically shouldn't be necessary if you're using typed maps exclusively, but could be useful when building abstractions on top of handles, as well as for accessing the accessors on Handle which are not otherwise directly exposed on TypedHandle.

pub const fn from_raw_parts(index: usize, generation: u16, meta: u16) -> Self[src]

Construct a handle from the separate parts.

Warning

This is a feature intended for advanced usage. An attempt is made to cope with dubious handles, but it's almost certainly possible to pierce the abstraction veil of the HandleMap if you use this.

However, it should not be possible to cause memory unsafety -- this crate has no unsafe code.

pub const fn from_raw(value: u64) -> Self[src]

Construct a handle from it's internal u64 value.

See the documentation for Handle::from_raw for further info.

Warning

This is a feature intended for advanced usage. An attempt is made to cope with dubious handles, but it's almost certainly possible to pierce the abstraction veil of the HandleMap if you use this.

However, it should not be possible to cause memory unsafety -- this crate has no unsafe code.

pub const fn into_raw(self) -> u64[src]

Get the internal u64 representation of this handle.

See the documentation for Handle::into_raw for further info.

pub const fn index(self) -> usize[src]

Returns the index value of this handle.

While a usize is returned, this value is guaranteed to be 32 bits.

See the documentation for Handle::index for further info.

pub const fn generation(self) -> u16[src]

Returns the generation value of this handle.

See the documentation for Handle::generation for further info.

pub const fn meta(self) -> u16[src]

Returns the metadata field of this handle.

See the documentation for Handle::meta for further info.

pub const fn map_id(self) -> u16[src]

Returns the metadata field of this handle. This is an alias for map_id, as in the common case, this is what the metadata field is used for.

See Handle::meta for more info.

Trait Implementations

impl<T> Clone for TypedHandle<T>[src]

impl<T> Copy for TypedHandle<T>[src]

impl<T> Debug for TypedHandle<T>[src]

impl<T> Default for TypedHandle<T>[src]

impl<T> Eq for TypedHandle<T>[src]

impl<T> Hash for TypedHandle<T>[src]

impl<T> Index<TypedHandle<T>> for TypedHandleMap<T>[src]

type Output = T

The returned type after indexing.

impl<T> IndexMut<TypedHandle<T>> for TypedHandleMap<T>[src]

impl<T> Ord for TypedHandle<T>[src]

impl<T> PartialEq<TypedHandle<T>> for TypedHandle<T>[src]

impl<T> PartialOrd<TypedHandle<T>> for TypedHandle<T>[src]

Auto Trait Implementations

impl<T> Send for TypedHandle<T>

impl<T> Sync for TypedHandle<T>

impl<T> Unpin for TypedHandle<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.