From 4077c33adfdacaf0ed68657a1955a7b69a78d373 Mon Sep 17 00:00:00 2001 From: Vlad Stepanov <8uk.8ak@gmail.com> Date: Thu, 15 Jun 2023 14:29:40 +0400 Subject: Builder interface for History objects (#933) * [feature] store env variables in History records WIP: remove `HistoryWithoutDelete`, add some docstrings, tests * Create History objects through builders. Assure in compile-time that all required fields are set for the given construction scenario * (from #882) split Cmd::run into subfns * Update `History` doc * remove rmp-serde from history * update warning --------- Co-authored-by: Conrad Ludgate --- atuin-client/src/import/nu_histdb.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'atuin-client/src/import/nu_histdb.rs') diff --git a/atuin-client/src/import/nu_histdb.rs b/atuin-client/src/import/nu_histdb.rs index 0fb5192e..34568d80 100644 --- a/atuin-client/src/import/nu_histdb.rs +++ b/atuin-client/src/import/nu_histdb.rs @@ -30,16 +30,19 @@ impl From for History { fn from(histdb_item: HistDbEntry) -> Self { let ts_secs = histdb_item.start_timestamp / 1000; let ts_ns = (histdb_item.start_timestamp % 1000) * 1_000_000; - History::new( - DateTime::from_utc(NaiveDateTime::from_timestamp(ts_secs, ts_ns as u32), Utc), - String::from_utf8(histdb_item.command_line).unwrap(), - String::from_utf8(histdb_item.cwd).unwrap(), - histdb_item.exit_status, - histdb_item.duration_ms, - Some(format!("{:x}", histdb_item.session_id)), - Some(String::from_utf8(histdb_item.hostname).unwrap()), - None, - ) + let imported = History::import() + .timestamp(DateTime::from_utc( + NaiveDateTime::from_timestamp(ts_secs, ts_ns as u32), + Utc, + )) + .command(String::from_utf8(histdb_item.command_line).unwrap()) + .cwd(String::from_utf8(histdb_item.cwd).unwrap()) + .exit(histdb_item.exit_status) + .duration(histdb_item.duration_ms) + .session(format!("{:x}", histdb_item.session_id)) + .hostname(String::from_utf8(histdb_item.hostname).unwrap()); + + imported.build().into() } } -- cgit v1.3.1