Skip to content

Commit

Permalink
Use static lifetime for read-only tables and transactions
Browse files Browse the repository at this point in the history
In the future, these lifetimes will be removed
  • Loading branch information
cberner committed Jan 20, 2024
1 parent 5bb2370 commit 04d2707
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ impl Database {
///
/// Returns a [`ReadTransaction`] which may be used to read from the database. Read transactions
/// may exist concurrently with writes
pub fn begin_read(&self) -> Result<ReadTransaction, TransactionError> {
pub fn begin_read(&self) -> Result<ReadTransaction<'static>, TransactionError> {
let guard = self.allocate_read_transaction()?;
#[cfg(feature = "logging")]
info!("Beginning read transaction id={:?}", guard.id());
Expand Down
10 changes: 5 additions & 5 deletions src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ pub struct ReadTransaction<'a> {
_lifetime: PhantomData<&'a ()>,
}

impl<'db> ReadTransaction<'db> {
impl<'a> ReadTransaction<'a> {
pub(crate) fn new(
mem: Arc<TransactionalMemory>,
guard: TransactionGuard,
Expand All @@ -1192,7 +1192,7 @@ impl<'db> ReadTransaction<'db> {
pub fn open_table<K: RedbKey + 'static, V: RedbValue + 'static>(
&self,
definition: TableDefinition<K, V>,
) -> Result<ReadOnlyTable<K, V>, TableError> {
) -> Result<ReadOnlyTable<'static, K, V>, TableError> {
let header = self
.tree
.get_table::<K, V>(definition.name(), TableType::Normal)?
Expand All @@ -1211,7 +1211,7 @@ impl<'db> ReadTransaction<'db> {
pub fn open_untyped_table(
&self,
handle: impl TableHandle,
) -> Result<ReadOnlyUntypedTable, TableError> {
) -> Result<ReadOnlyUntypedTable<'static>, TableError> {
let header = self
.tree
.get_table_untyped(handle.name(), TableType::Normal)?
Expand All @@ -1229,7 +1229,7 @@ impl<'db> ReadTransaction<'db> {
pub fn open_multimap_table<K: RedbKey + 'static, V: RedbKey + 'static>(
&self,
definition: MultimapTableDefinition<K, V>,
) -> Result<ReadOnlyMultimapTable<K, V>, TableError> {
) -> Result<ReadOnlyMultimapTable<'static, K, V>, TableError> {
let header = self
.tree
.get_table::<K, V>(definition.name(), TableType::Multimap)?
Expand All @@ -1247,7 +1247,7 @@ impl<'db> ReadTransaction<'db> {
pub fn open_untyped_multimap_table(
&self,
handle: impl MultimapTableHandle,
) -> Result<ReadOnlyUntypedMultimapTable, TableError> {
) -> Result<ReadOnlyUntypedMultimapTable<'static>, TableError> {
let header = self
.tree
.get_table_untyped(handle.name(), TableType::Multimap)?
Expand Down

0 comments on commit 04d2707

Please sign in to comment.