pub struct BuildInfo {
pub version: &'static str,
pub build: u64,
pub started_at: String,
}Expand description
Runtime build metadata surfaced to logs, the --version flag, and
downstream instrumentation.
Why: Centralizes “which binary + which invocation” so later instrumentation
can tag every telemetry event with the same build stamp the startup log
line shows.
What: Holds the compile-time semver, the incremented build counter, and
the ISO8601 UTC start timestamp.
Test: display_string returns <pkg-name> vX.Y.Z build #N.
Fields§
§version: &'static str§build: u64§started_at: StringImplementations§
Source§impl BuildInfo
impl BuildInfo
Sourcepub async fn load_and_increment(state_dir: &Path) -> Result<Self>
pub async fn load_and_increment(state_dir: &Path) -> Result<Self>
Load the persistent counter, increment it, and persist back using the given state directory.
Why: Single entry point ensures every process start gets a fresh
build number even if the caller forgets to save.
What: Uses <state_dir>/build.json. See load_and_increment_in for
the testable, directory-parameterized version.
Test: See load_and_increment_in tests.
Sourcepub async fn load_and_increment_in(dir: &Path) -> Result<Self>
pub async fn load_and_increment_in(dir: &Path) -> Result<Self>
Same as load_and_increment but with an explicit base directory.
Why: Tests need to drive the counter against a temp dir without
mutating the real state directory in the project.
What: Creates <dir> if missing, reads/parses <dir>/build.json
(treating missing or malformed as build=0), increments, writes back
atomically.
Test: See unit tests at the bottom of this file.
Sourcepub fn display_string(&self) -> String
pub fn display_string(&self) -> String
Human-readable banner used by the startup log line and --version.
Why: Single canonical format so grep/tooling can match it uniformly.
What: <pkg-name> vX.Y.Z build #N.
Test: Asserted directly in unit tests.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BuildInfo
impl RefUnwindSafe for BuildInfo
impl Send for BuildInfo
impl Sync for BuildInfo
impl Unpin for BuildInfo
impl UnsafeUnpin for BuildInfo
impl UnwindSafe for BuildInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more