pub enum SharedAny<T> {
Sync(Shared<T>),
Async(AsyncShared<T>),
}Expand description
A universal container that can hold either sync or async variants.
This enum allows writing generic code that works with both sync and async containers,
but requires explicit handling of the mode mismatch via Result.
Variants§
Implementations§
Sourcepub fn downgrade(&self) -> WeakSharedAny<T>
pub fn downgrade(&self) -> WeakSharedAny<T>
Creates a weak reference to this container.
Trait Implementations§
Source§async fn read_async<'a>(&'a self) -> AsyncReadGuard<'a, T>where
T: 'a,
async fn read_async<'a>(&'a self) -> AsyncReadGuard<'a, T>where
T: 'a,
Asynchronously acquires a read lock on the container.
Source§async fn write_async<'a>(&'a self) -> AsyncWriteGuard<'a, T>where
T: 'a,
async fn write_async<'a>(&'a self) -> AsyncWriteGuard<'a, T>where
T: 'a,
Asynchronously acquires a write lock on the container.
Source§async fn get_cloned_async(&self) -> Twhere
T: Clone,
async fn get_cloned_async(&self) -> Twhere
T: Clone,
Asynchronously gets a clone of the contained value.
Source§fn from(shared: AsyncShared<T>) -> Self
fn from(shared: AsyncShared<T>) -> Self
Converts to this type from the input type.
Source§fn read(&self) -> Result<SyncReadGuard<'_, T>, AccessError>
fn read(&self) -> Result<SyncReadGuard<'_, T>, AccessError>
Acquires a read lock on the container.
Source§fn write(&self) -> Result<SyncWriteGuard<'_, T>, AccessError>
fn write(&self) -> Result<SyncWriteGuard<'_, T>, AccessError>
Acquires a write lock on the container.
Source§fn get_cloned(&self) -> Result<T, AccessError>where
T: Clone,
fn get_cloned(&self) -> Result<T, AccessError>where
T: Clone,
Gets a clone of the contained value.
Auto Trait Implementations§
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