diff --git a/src/builder.rs b/src/builder.rs index 38206f46..5bd32dbd 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -248,11 +248,11 @@ impl Builder { /// use orderwal::Builder; /// /// let options = Builder::new(); - /// assert_eq!(options.sync_on_write(), true); + /// assert_eq!(options.sync(), true); /// ``` #[inline] - pub const fn sync_on_write(&self) -> bool { - self.opts.sync_on_write() + pub const fn sync(&self) -> bool { + self.opts.sync() } /// Sets the capacity of the WAL. @@ -316,12 +316,12 @@ impl Builder { /// ```rust /// use orderwal::Builder; /// - /// let options = Builder::new().with_sync_on_write(false); - /// assert_eq!(options.sync_on_write(), false); + /// let options = Builder::new().with_sync(false); + /// assert_eq!(options.sync(), false); /// ``` #[inline] - pub const fn with_sync_on_write(mut self, sync: bool) -> Self { - self.opts = self.opts.with_sync_on_write(sync); + pub const fn with_sync(mut self, sync: bool) -> Self { + self.opts = self.opts.with_sync(sync); self } diff --git a/src/options.rs b/src/options.rs index 97ee7c67..6ec2146d 100644 --- a/src/options.rs +++ b/src/options.rs @@ -3,7 +3,7 @@ pub struct Options { maximum_key_size: u32, maximum_value_size: u32, - sync_on_write: bool, + sync: bool, magic_version: u16, cap: Option, reserved: u32, @@ -46,7 +46,7 @@ impl Options { Self { maximum_key_size: u16::MAX as u32, maximum_value_size: u32::MAX, - sync_on_write: true, + sync: true, magic_version: 0, huge: None, cap: None, @@ -229,11 +229,11 @@ impl Options { /// use orderwal::Options; /// /// let options = Options::new(); - /// assert_eq!(options.sync_on_write(), true); + /// assert_eq!(options.sync(), true); /// ``` #[inline] - pub const fn sync_on_write(&self) -> bool { - self.sync_on_write + pub const fn sync(&self) -> bool { + self.sync } /// Sets the capacity of the WAL. @@ -297,12 +297,12 @@ impl Options { /// ```rust /// use orderwal::Options; /// - /// let options = Options::new().with_sync_on_write(false); - /// assert_eq!(options.sync_on_write(), false); + /// let options = Options::new().with_sync(false); + /// assert_eq!(options.sync(), false); /// ``` #[inline] - pub const fn with_sync_on_write(mut self, sync: bool) -> Self { - self.sync_on_write = sync; + pub const fn with_sync(mut self, sync: bool) -> Self { + self.sync = sync; self } diff --git a/src/swmr/generic.rs b/src/swmr/generic.rs index ac294049..0bdf6413 100644 --- a/src/swmr/generic.rs +++ b/src/swmr/generic.rs @@ -835,9 +835,9 @@ where buf[0] = committed_flag.bits; let buf_cap = buf.capacity(); - if self.core.opts.sync_on_write() && allocator.is_ondisk() { + if self.core.opts.sync() && allocator.is_ondisk() { allocator - .flush_range(buf.offset(), buf_cap) + .flush_header_and_range(buf.offset(), buf_cap) .map_err(|e| Among::Right(e.into()))?; } buf.detach(); @@ -903,11 +903,11 @@ where // commit the entry buf[0] |= Flags::COMMITTED.bits(); - if self.core.opts.sync_on_write() && self.core.arena.is_ondisk() { + if self.core.opts.sync() && self.core.arena.is_ondisk() { self .core .arena - .flush_range(buf.offset(), elen as usize) + .flush_header_and_range(buf.offset(), elen as usize) .map_err(|e| Among::Right(e.into()))?; } buf.detach(); diff --git a/src/swmr/generic/builder.rs b/src/swmr/generic/builder.rs index 157d303c..269b5c5d 100644 --- a/src/swmr/generic/builder.rs +++ b/src/swmr/generic/builder.rs @@ -182,11 +182,11 @@ impl GenericBuilder { /// use orderwal::swmr::GenericBuilder; /// /// let options = GenericBuilder::new(); - /// assert_eq!(options.sync_on_write(), true); + /// assert_eq!(options.sync(), true); /// ``` #[inline] - pub const fn sync_on_write(&self) -> bool { - self.opts.sync_on_write() + pub const fn sync(&self) -> bool { + self.opts.sync() } /// Sets the capacity of the WAL. @@ -250,12 +250,12 @@ impl GenericBuilder { /// ```rust /// use orderwal::swmr::GenericBuilder; /// - /// let options = GenericBuilder::new().with_sync_on_write(false); - /// assert_eq!(options.sync_on_write(), false); + /// let options = GenericBuilder::new().with_sync(false); + /// assert_eq!(options.sync(), false); /// ``` #[inline] - pub const fn with_sync_on_write(mut self, sync: bool) -> Self { - self.opts = self.opts.with_sync_on_write(sync); + pub const fn with_sync(mut self, sync: bool) -> Self { + self.opts = self.opts.with_sync(sync); self } diff --git a/src/wal/sealed.rs b/src/wal/sealed.rs index c67b3303..9d605f24 100644 --- a/src/wal/sealed.rs +++ b/src/wal/sealed.rs @@ -350,7 +350,7 @@ pub trait Sealed: Constructor { // commit the entry buf[0] |= Flags::COMMITTED.bits(); - if self.options().sync_on_write() && is_ondisk { + if self.options().sync() && is_ondisk { allocator .flush_header_and_range(buf.offset(), elen as usize) .map_err(|e| Among::Right(e.into()))?; @@ -395,7 +395,7 @@ trait SealedExt: Sealed { buf[0] = committed_flag.bits; let buf_cap = buf.capacity(); - if self.options().sync_on_write() && allocator.is_ondisk() { + if self.options().sync() && allocator.is_ondisk() { allocator.flush_header_and_range(buf.offset(), buf_cap)?; } buf.detach();