Skip to content

Commit 9d8fb8a

Browse files
committed
docs(api): fix peek_version adjacent stuff
1 parent f7e39b7 commit 9d8fb8a

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/records.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
//! ```
4040
4141
use std::fmt::{Display, Write};
42-
use std::hash::{Hash, Hasher};
42+
use std::hash::Hash;
4343
use std::net::IpAddr;
4444

4545
use chrono::{DateTime, Local, TimeZone, Utc};

src/store.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ pub const ZSTD_COMPRESSION_LEVEL: i32 = 4;
6060
/// Primarily intended for development and testing.
6161
pub const ENV_PATH: &str = "NETPULSE_STORE_PATH";
6262

63+
/// How long to wait between running workloads for the daemon
6364
pub const DEFAULT_PERIOD: i64 = 60;
65+
/// Environment variable name for the time period after which the daemon wakes up.
66+
///
67+
/// If set, its value will be used instead of [DEFAULT_PERIOD].
68+
/// Primarily intended for development and testing.
6469
pub const ENV_PERIOD: &str = "NETPULSE_PERIOD";
6570

6671
/// Version information for the store format.
@@ -630,36 +635,39 @@ impl Store {
630635
&mut self.checks
631636
}
632637

633-
/// Reads only the version field from a store file without loading the entire store.
638+
/// Reads only the [Version] from a store file without loading the entire [Store].
634639
///
635640
/// This function efficiently checks the store version by:
636-
/// 1. Opening the store file
641+
/// 1. Opening the store file (decompressing it if enabled)
637642
/// 2. Deserializing only the version field
638643
/// 3. Skipping the rest of the data
639644
///
640645
/// This is more efficient than loading the full store when only version
641-
/// information is needed, such as during version compatibility checks.
646+
/// information is needed, such as during version compatibility checks. It may also keep
647+
/// working if the format/version of the store is incompatible with what this version of
648+
/// netpulse uses.
642649
///
643650
/// # Feature Flags
644651
///
645652
/// If the "compression" feature is enabled, this function will decompress
646-
/// the store file using zstd before reading the version.
653+
/// the store file using [zstd] before reading the version.
647654
///
648655
/// # Errors
649656
///
650657
/// Returns [StoreError] if:
651658
/// - Store file doesn't exist ([`StoreError::DoesNotExist`])
652659
/// - Store file is corrupt or truncated ([`StoreError::Load`])
653-
/// - File permissions prevent reading
654-
/// - Decompression fails (with "compression" feature)
660+
/// - File permissions prevent reading ([`StoreError::Io`])
661+
/// - Decompression fails (with "compression" feature) ([`StoreError::Io`])
655662
///
656663
/// # Examples
657664
///
658665
/// ```rust,no_run
659-
/// use netpulse::Store;
666+
/// use netpulse::store::Store;
667+
/// use netpulse::errors::StoreError;
660668
///
661669
/// match Store::peek_file_version() {
662-
/// Ok(version) => println!("Store version: {}", version),
670+
/// Ok(version) => println!("Store version in file: {}", version),
663671
/// Err(StoreError::DoesNotExist) => println!("No store file found"),
664672
/// Err(e) => eprintln!("Error reading store version: {}", e),
665673
/// }

0 commit comments

Comments
 (0)