pub struct UniqueArc<T> { /* private fields */ }Expand description
A smart pointer which has exactly one strong reference to the inner type, but may have several weak references.
This type is intentionally !Clone so that we know for a fact that it can be
safely unpacked.
Implementations§
Source§impl UniqueArc<Transaction>
impl UniqueArc<Transaction>
Sourcepub async fn commit(self) -> Result<(), CryptoKeystoreError>
pub async fn commit(self) -> Result<(), CryptoKeystoreError>
Persists all the operations in the database.
Sourcepub async fn rollback(self) -> CryptoKeystoreResult<()>
pub async fn rollback(self) -> CryptoKeystoreResult<()>
Roll back this transaction in the database.
There are two differences between manual rollback and implicit:
- manual rollback clears the database’s weak transaction ref
- manual rollback permits propagation of db-level errors
Source§impl<T> UniqueArc<T>
impl<T> UniqueArc<T>
Sourcepub async fn into_inner(this: Self) -> T
pub async fn into_inner(this: Self) -> T
Unpack this UniqueArc, returning the inner value.
This waits for any in-flight UniqueWeak::upgrade / UniqueWeak::upgrade_sync
guard to drop before unpacking, so that the sole remaining strong reference is the one
held by this UniqueArc.
Trait Implementations§
Source§impl<T> FetchFromDatabase for UniqueArc<T>where
T: FetchFromDatabase,
impl<T> FetchFromDatabase for UniqueArc<T>where
T: FetchFromDatabase,
Source§fn get<'life0, 'life1, 'async_trait, E>(
&'life0 self,
id: &'life1 E::PrimaryKey,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Option<Arc<E>>>> + Send + 'async_trait>>
fn get<'life0, 'life1, 'async_trait, E>( &'life0 self, id: &'life1 E::PrimaryKey, ) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Option<Arc<E>>>> + Send + 'async_trait>>
Get an instance of E from the database by its primary key.
Source§fn count<'life0, 'async_trait, E>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<u32>> + Send + 'async_trait>>
fn count<'life0, 'async_trait, E>( &'life0 self, ) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<u32>> + Send + 'async_trait>>
Count the number of Es in the database.
Source§fn load_all<'life0, 'async_trait, E>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Vec<Arc<E>>>> + Send + 'async_trait>>
fn load_all<'life0, 'async_trait, E>( &'life0 self, ) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Vec<Arc<E>>>> + Send + 'async_trait>>
Load all Es from the database.
Source§fn get_borrowed<'life0, 'life1, 'async_trait, E>(
&'life0 self,
id: <E as BorrowPrimaryKey>::BorrowedPrimaryKey<'life1>,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Option<Arc<E>>>> + Send + 'async_trait>>where
E: 'static + EntityGetBorrowed + Clone + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_borrowed<'life0, 'life1, 'async_trait, E>(
&'life0 self,
id: <E as BorrowPrimaryKey>::BorrowedPrimaryKey<'life1>,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Option<Arc<E>>>> + Send + 'async_trait>>where
E: 'static + EntityGetBorrowed + Clone + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get an instance of E from the database by the borrowed form of its primary key.
Source§fn get_unique<'a, 'life0, 'async_trait, U>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Option<Arc<U>>>> + Send + 'async_trait>>where
U: 'static + UniqueEntityExt + Entity + Clone + Send + Sync + 'async_trait,
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn get_unique<'a, 'life0, 'async_trait, U>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Option<Arc<U>>>> + Send + 'async_trait>>where
U: 'static + UniqueEntityExt + Entity + Clone + Send + Sync + 'async_trait,
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Get the requested unique entity from the database.
Source§fn exists<'a, 'life0, 'async_trait, U>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<bool>> + Send + 'async_trait>>where
U: 'static + UniqueEntityExt + Entity + Clone + Send + Sync + 'async_trait,
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn exists<'a, 'life0, 'async_trait, U>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<bool>> + Send + 'async_trait>>where
U: 'static + UniqueEntityExt + Entity + Clone + Send + Sync + 'async_trait,
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Determine whether a unique entity is present in the database.