pub trait BorrowPrimaryKey: Entity {
type BorrowedPrimaryKey: ?Sized + ToOwned<Owned = Self::PrimaryKey>;
// Required methods
fn borrow_primary_key(&self) -> &Self::BorrowedPrimaryKey;
fn get_borrowed<'life0, 'life1, 'async_trait, Q>(
conn: &'life0 mut Self::ConnectionType,
key: &'life1 Q,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Option<Self>>> + Send + 'async_trait>>
where Self::PrimaryKey: Borrow<Q>,
Q: KeyType + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
An extension trait which should be implemented for all entities whose primary key has a distinct borrowed form.
i.e. String, Vec<u8>, etc.
Required Associated Types§
type BorrowedPrimaryKey: ?Sized + ToOwned<Owned = Self::PrimaryKey>
Required Methods§
Sourcefn borrow_primary_key(&self) -> &Self::BorrowedPrimaryKey
fn borrow_primary_key(&self) -> &Self::BorrowedPrimaryKey
Borrow this entity’s primary key without copying any data.
This borrowed key has a lifetime tied to that of this entity.
Sourcefn get_borrowed<'life0, 'life1, 'async_trait, Q>(
conn: &'life0 mut Self::ConnectionType,
key: &'life1 Q,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Option<Self>>> + Send + 'async_trait>>where
Self::PrimaryKey: Borrow<Q>,
Q: KeyType + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_borrowed<'life0, 'life1, 'async_trait, Q>(
conn: &'life0 mut Self::ConnectionType,
key: &'life1 Q,
) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Option<Self>>> + Send + 'async_trait>>where
Self::PrimaryKey: Borrow<Q>,
Q: KeyType + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get an entity by a borrowed form of its primary key.
The type signature here is somewhat complicated, but it breaks down simply: if our primary key is something
like Vec<u8>, we want to be able to use this method even if what we have on hand is &[u8].
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.