pub struct ShardRegistry { /* private fields */ }
Implementations§
Source§impl ShardRegistry
impl ShardRegistry
Sourcepub fn get() -> &'static Self
pub fn get() -> &'static Self
Get the singleton instance of the shard registry.
Should only be called by macro, not manually.
Sourcepub unsafe fn init_or_get<T, F, R>(&self, id: &str, f: F) -> R
pub unsafe fn init_or_get<T, F, R>(&self, id: &str, f: F) -> R
Get or initialize and get a shard state, and provide it to the closure f
as Arc<T>
. The state type must implement ShardState
.
This function should never be called manually; it should be automatically generated by the #[shard]
macro.
§Safety
This function is unsafe because it uses an evil method to cast Arc<dyn ShardState>
to Arc<T>
.
Auto Trait Implementations§
impl Freeze for ShardRegistry
impl !RefUnwindSafe for ShardRegistry
impl Send for ShardRegistry
impl Sync for ShardRegistry
impl Unpin for ShardRegistry
impl !UnwindSafe for ShardRegistry
Blanket Implementations§
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