aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/history/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/turtle/src/history/mod.rs')
-rw-r--r--crates/turtle/src/history/mod.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/crates/turtle/src/history/mod.rs b/crates/turtle/src/history/mod.rs
index 27755bbe..3617bc54 100644
--- a/crates/turtle/src/history/mod.rs
+++ b/crates/turtle/src/history/mod.rs
@@ -2,6 +2,8 @@ use core::fmt::Formatter;
use regex::RegexSet;
use std::env;
use std::fmt::Display;
+use std::time::Duration;
+use uuid::Uuid;
use turtle_common::utils::uuid_v7;
@@ -15,8 +17,8 @@ mod secrets;
const HISTORY_AUTHOR_ENV: &str = "ATUIN_HISTORY_AUTHOR";
const HISTORY_INTENT_ENV: &str = "ATUIN_HISTORY_INTENT";
-#[derive(Clone, Debug, Eq, PartialEq, Hash)]
-pub struct HistoryId(pub String);
+#[derive(Clone, Debug, Eq, PartialEq, Hash, Copy)]
+pub struct HistoryId(Uuid);
impl Display for HistoryId {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
@@ -26,7 +28,12 @@ impl Display for HistoryId {
impl From<String> for HistoryId {
fn from(s: String) -> Self {
- Self(s)
+ Self(Uuid::parse_str(&s).expect("should be a valid uuid"))
+ }
+}
+impl From<&str> for HistoryId {
+ fn from(s: &str) -> Self {
+ Self(Uuid::parse_str(s).expect("should be a valid uuid"))
}
}
@@ -54,7 +61,7 @@ pub struct History {
pub timestamp: OffsetDateTime,
/// How long the command took to run.
- pub duration: i64,
+ pub duration: Duration,
/// The exit code of the command.
pub exit: i64,
@@ -106,7 +113,7 @@ impl History {
command: String,
cwd: String,
exit: i64,
- duration: i64,
+ duration: Duration,
session: String,
hostname: String,
author: Option<String>,