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

A partially initialized object store containing potentially uninitialized objects. Supports reserving slots for data and provides handles. Does not allow access to any contained data until the store is converted to an ObjectStore using UninitObjectStore::try_init. This is only possible when every handle has been written to.

Implementations

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

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

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

Instantiates a new UninitObjectStore object.

If every reserved handle has been written to, returns Ok with an initialized ObjectStore. Otherwise, returns Err(self).

Iterates over unwritten handles in this store. Intended mainly for diagnostics.

Returns the number of objects in this store that are yet to be written.

Returns true if a call to UninitObjectStore::try_init will succeed.

Pushes a reservation for 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. This handle must later be written to with UninitObjectStore::write, otherwise initializing the store will panic.

If the given handle has not already been written to, writes the given value to it. Otherwise, panics. Also panics if the handle is not associated with this object store.

If the given handle has not already been written to, writes the given value to it and returns true. Otherwise, returns false. Panics if the handle is not associated with this object store.

Reserves a new object in 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 UninitObjectStore. 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 UninitObjectStore.

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

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 UninitObjectStore.

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

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

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

Trait Implementations

An uninit object store as Send as long as its tag is Send because the tag ensures that all stored objects are Send.

An uninit object store can be safely accessed from any thread regardless of its tag because objects inside it cannot be accessed while it is uninitialized.

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.