pub struct ObjectStore<Tag = Send> { /* private fields */ }
Expand description

Stores arbitrary objects as long as they implement Castable and tag::Satisfies<Tag> for the choice of Tag.

See the module documentation for more info.

Implementations

Instantiates a new ObjectStore object that can store objects which are !Send and !Sync.

Instantiates a new ObjectStore object that can store objects which are Send but !Sync.

Instantiates a new ObjectStore object that can store objects which are Send and Sync.

Instantiates a new ObjectStore object.

Pushes a new object to the given buffer and returns a handle for it. Any u32 can be chosen as the buffer_ix but bear in mind that a large choice of index will cause a large allocation to happen if smaller buffer indexes have not yet been used.

Iterates over handles for all stored objects in the given buffer that are castable to the requested type. This is a fast operation implemented as a range lookup in a BTreeSet.

Iterates over dynamic handles for all stored objects in the given buffer that are castable to the requested type. This is a fast operation implemented as a range lookup in a BTreeSet.

Casts an untyped DynamicHandle up to a typed Handle. Panics if the input handle is not associated with this ObjectStore. Returns None if the object that the handle points to is not castable to the requested type.

Casts a handle down to an untyped DynamicHandle. Panics if the input handle is not associated with this ObjectStore.

Casts a handle to a different type. Panics if the input handle is not associated with this ObjectStore. Returns None if the concrete type pointed to by the input handle is not castable to U.

Accesses an object reference through a handle. Panics if the handle is not associated with this ObjectStore. This is very cheap: about as cheap as a bounds-checked index into an array.

Accesses a mutable object reference through a handle. Panics if the handle is not associated with this ObjectStore. This is very cheap: about as cheap as a bounds-checked index into an array.

Returns the TypeId of the concrete type stored at the given handle. The returned type id will not match T if T is a trait object type. Panics if the input handle is not associated with this ObjectStore.

Returns the TypeId of the concrete type stored at the given handle. Panics if the input handle is not associated with this ObjectStore.

Gets the name of the type stored at the given handle. Panics if the input handle is not associated with this ObjectStore.

Gets the name of the type stored at the given dynamic handle. Panics if the input handle is not associated with this ObjectStore.

Trait Implementations

The object store as Send if its tag is Send because this ensures that all contained objects are Send.

The object store as Sync if its tag is Sync because this ensures that all contained objects are Sync.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.