Skip to content

Commit

Permalink
Fix some derive trait issues on EnvOpenOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerollmops committed Dec 20, 2024
1 parent 8f6db07 commit a4c3bd2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
24 changes: 14 additions & 10 deletions heed/src/envs/env_open_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::txn::{TlsUsage, WithoutTls};
use crate::{EnvFlags, Error, Result, WithTls};

/// Options and flags which can be used to configure how an environment is opened.
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct EnvOpenOptions<T: TlsUsage> {
map_size: Option<usize>,
Expand All @@ -36,12 +36,6 @@ pub struct EnvOpenOptions<T: TlsUsage> {
_tls_marker: PhantomData<T>,
}

impl Default for EnvOpenOptions<WithTls> {
fn default() -> Self {
Self::new()
}
}

impl EnvOpenOptions<WithTls> {
/// Creates a blank new set of options ready for configuration.
pub fn new() -> EnvOpenOptions<WithTls> {
Expand Down Expand Up @@ -136,9 +130,6 @@ impl<T: TlsUsage> EnvOpenOptions<T> {
let Self { map_size, max_readers, max_dbs, flags, _tls_marker: _ } = self;
EnvOpenOptions { map_size, max_readers, max_dbs, flags, _tls_marker: PhantomData }
}
}

impl<T: TlsUsage> EnvOpenOptions<T> {
/// Set the size of the memory map to use for this environment.
///
/// It must be a multiple of the OS page size.
Expand Down Expand Up @@ -494,3 +485,16 @@ impl<T: TlsUsage> EnvOpenOptions<T> {
}
}
}

impl Default for EnvOpenOptions<WithTls> {
fn default() -> Self {
Self::new()
}
}

impl<T: TlsUsage> Clone for EnvOpenOptions<T> {
fn clone(&self) -> Self {
let Self { map_size, max_readers, max_dbs, flags, _tls_marker } = *self;
EnvOpenOptions { map_size, max_readers, max_dbs, flags, _tls_marker }
}
}
2 changes: 2 additions & 0 deletions heed/src/txn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ impl<T> Drop for RoTxn<'_, T> {
/// at a time, plus any child (nested) transactions. Each transaction belongs
/// to one thread. A `BadRslot` error will be thrown when multiple read
/// transactions exists on the same thread.
#[derive(Debug, PartialEq, Eq)]
pub enum WithTls {}

/// Parameter defining that read transactions are opened without
Expand All @@ -132,6 +133,7 @@ pub enum WithTls {}
/// When used to open transactions: A thread can use any number
/// of read transactions at a time on the same thread. Read transactions
/// can be moved in between threads (`Send`).
#[derive(Debug, PartialEq, Eq)]
pub enum WithoutTls {}

/// Specifycies if Thread Local Storage (TLS) must be used when
Expand Down

0 comments on commit a4c3bd2

Please sign in to comment.