aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/atuin_client
diff options
context:
space:
mode:
Diffstat (limited to 'crates/turtle/src/atuin_client')
-rw-r--r--crates/turtle/src/atuin_client/database.rs6
-rw-r--r--crates/turtle/src/atuin_client/history.rs10
-rw-r--r--crates/turtle/src/atuin_client/history/builder.rs10
-rw-r--r--crates/turtle/src/atuin_client/settings.rs70
4 files changed, 48 insertions, 48 deletions
diff --git a/crates/turtle/src/atuin_client/database.rs b/crates/turtle/src/atuin_client/database.rs
index 6a2d5887..24f017be 100644
--- a/crates/turtle/src/atuin_client/database.rs
+++ b/crates/turtle/src/atuin_client/database.rs
@@ -74,7 +74,7 @@ pub(crate) async fn current_context() -> eyre::Result<Context> {
impl Context {
pub(crate) fn from_history(entry: &History) -> Self {
- Context {
+ Self {
session: entry.session.clone(),
cwd: entry.cwd.clone(),
hostname: entry.hostname.clone(),
@@ -89,7 +89,7 @@ fn get_session_start_time(session_id: &str) -> Option<i64> {
&& let Some(timestamp) = uuid.get_timestamp()
{
let (seconds, nanos) = timestamp.to_unix();
- return Some(seconds as i64 * 1_000_000_000 + nanos as i64);
+ return Some(seconds as i64 * 1_000_000_000 + i64::from(nanos));
}
None
}
@@ -205,7 +205,7 @@ impl ClientSqlite {
.author(author)
.intent(intent)
.deleted_at(
- deleted_at.and_then(|t| OffsetDateTime::from_unix_timestamp_nanos(t as i128).ok()),
+ deleted_at.and_then(|t| OffsetDateTime::from_unix_timestamp_nanos(i128::from(t)).ok()),
)
.build()
.into()
diff --git a/crates/turtle/src/atuin_client/history.rs b/crates/turtle/src/atuin_client/history.rs
index 11d60548..c38d8ccc 100644
--- a/crates/turtle/src/atuin_client/history.rs
+++ b/crates/turtle/src/atuin_client/history.rs
@@ -223,7 +223,7 @@ impl History {
}
}
- fn deserialize_v0(bytes: &[u8]) -> Result<History> {
+ fn deserialize_v0(bytes: &[u8]) -> Result<Self> {
use rmp::decode;
fn error_report<E: std::fmt::Debug>(err: E) -> eyre::Report {
@@ -270,7 +270,7 @@ impl History {
bail!("trailing bytes in encoded history. malformed")
}
- Ok(History {
+ Ok(Self {
id: id.to_owned().into(),
timestamp: OffsetDateTime::from_unix_timestamp_nanos(i128::from(timestamp))?,
duration,
@@ -287,7 +287,7 @@ impl History {
})
}
- fn deserialize_v1(bytes: &[u8]) -> Result<History> {
+ fn deserialize_v1(bytes: &[u8]) -> Result<Self> {
use rmp::decode;
fn error_report<E: std::fmt::Debug>(err: E) -> eyre::Report {
@@ -341,7 +341,7 @@ impl History {
bail!("trailing bytes in encoded history. malformed")
}
- Ok(History {
+ Ok(Self {
id: id.to_owned().into(),
timestamp: OffsetDateTime::from_unix_timestamp_nanos(i128::from(timestamp))?,
duration,
@@ -358,7 +358,7 @@ impl History {
})
}
- pub(crate) fn deserialize(bytes: &[u8], version: &str) -> Result<History> {
+ pub(crate) fn deserialize(bytes: &[u8], version: &str) -> Result<Self> {
match version {
HISTORY_VERSION_V0 => Self::deserialize_v0(bytes),
HISTORY_VERSION_V1 => Self::deserialize_v1(bytes),
diff --git a/crates/turtle/src/atuin_client/history/builder.rs b/crates/turtle/src/atuin_client/history/builder.rs
index 50a9d2af..daa4ef49 100644
--- a/crates/turtle/src/atuin_client/history/builder.rs
+++ b/crates/turtle/src/atuin_client/history/builder.rs
@@ -28,7 +28,7 @@ pub(crate) struct HistoryImported {
impl From<HistoryImported> for History {
fn from(imported: HistoryImported) -> Self {
- History::new(
+ Self::new(
imported.timestamp,
imported.command,
imported.cwd,
@@ -63,7 +63,7 @@ pub(crate) struct HistoryCaptured {
impl From<HistoryCaptured> for History {
fn from(captured: HistoryCaptured) -> Self {
- History::new(
+ Self::new(
captured.timestamp,
captured.command,
captured.cwd,
@@ -98,7 +98,7 @@ pub(crate) struct HistoryFromDb {
impl From<HistoryFromDb> for History {
fn from(from_db: HistoryFromDb) -> Self {
- History {
+ Self {
id: from_db.id.into(),
timestamp: from_db.timestamp,
exit: from_db.exit,
@@ -117,7 +117,7 @@ impl From<HistoryFromDb> for History {
/// Builder for a history entry that is captured via hook and sent to the daemon
///
/// This builder is similar to Capture, but we just require more information up front.
-/// For the old setup, we could just rely on History::new to read some of the missing
+/// For the old setup, we could just rely on `History::new` to read some of the missing
/// data. This is no longer the case.
#[derive(Debug, Clone, TypedBuilder)]
pub(crate) struct HistoryDaemonCapture {
@@ -138,7 +138,7 @@ pub(crate) struct HistoryDaemonCapture {
impl From<HistoryDaemonCapture> for History {
fn from(captured: HistoryDaemonCapture) -> Self {
- History::new(
+ Self::new(
captured.timestamp,
captured.command,
captured.cwd,
diff --git a/crates/turtle/src/atuin_client/settings.rs b/crates/turtle/src/atuin_client/settings.rs
index 074b2634..bfb8d001 100644
--- a/crates/turtle/src/atuin_client/settings.rs
+++ b/crates/turtle/src/atuin_client/settings.rs
@@ -49,25 +49,25 @@ pub(crate) enum SearchMode {
impl SearchMode {
pub(crate) fn as_str(self) -> &'static str {
match self {
- SearchMode::Prefix => "PREFIX",
- SearchMode::FullText => "FULLTXT",
- SearchMode::Fuzzy => "FUZZY",
- SearchMode::Skim => "SKIM",
- SearchMode::DaemonFuzzy => "DAEMON",
+ Self::Prefix => "PREFIX",
+ Self::FullText => "FULLTXT",
+ Self::Fuzzy => "FUZZY",
+ Self::Skim => "SKIM",
+ Self::DaemonFuzzy => "DAEMON",
}
}
pub(crate) fn next(self, settings: &Settings) -> Self {
match self {
- SearchMode::Prefix => SearchMode::FullText,
+ Self::Prefix => Self::FullText,
// if the user is using skim, we go to skim
- SearchMode::FullText if settings.search_mode == SearchMode::Skim => SearchMode::Skim,
+ Self::FullText if settings.search_mode == Self::Skim => Self::Skim,
// if the user is using daemon-fuzzy, we go to daemon-fuzzy
- SearchMode::FullText if settings.search_mode == SearchMode::DaemonFuzzy => {
- SearchMode::DaemonFuzzy
+ Self::FullText if settings.search_mode == Self::DaemonFuzzy => {
+ Self::DaemonFuzzy
}
// otherwise fuzzy.
- SearchMode::FullText => SearchMode::Fuzzy,
- SearchMode::Fuzzy | SearchMode::Skim | SearchMode::DaemonFuzzy => SearchMode::Prefix,
+ Self::FullText => Self::Fuzzy,
+ Self::Fuzzy | Self::Skim | Self::DaemonFuzzy => Self::Prefix,
}
}
}
@@ -96,12 +96,12 @@ pub(crate) enum FilterMode {
impl FilterMode {
pub(crate) fn as_str(self) -> &'static str {
match self {
- FilterMode::Global => "GLOBAL",
- FilterMode::Host => "HOST",
- FilterMode::Session => "SESSION",
- FilterMode::Directory => "DIRECTORY",
- FilterMode::Workspace => "WORKSPACE",
- FilterMode::SessionPreload => "SESSION+",
+ Self::Global => "GLOBAL",
+ Self::Host => "HOST",
+ Self::Session => "SESSION",
+ Self::Directory => "DIRECTORY",
+ Self::Workspace => "WORKSPACE",
+ Self::SessionPreload => "SESSION+",
}
}
}
@@ -127,10 +127,10 @@ pub(crate) enum Dialect {
}
impl From<Dialect> for interim::Dialect {
- fn from(d: Dialect) -> interim::Dialect {
+ fn from(d: Dialect) -> Self {
match d {
- Dialect::Uk => interim::Dialect::Uk,
- Dialect::Us => interim::Dialect::Us,
+ Dialect::Uk => Self::Uk,
+ Dialect::Us => Self::Us,
}
}
}
@@ -324,7 +324,7 @@ impl Keys {
/// The standard default values for all `[keys]` options.
/// These match the config defaults set in `builder_with_data_dir()`.
pub(crate) fn standard_defaults() -> Self {
- Keys {
+ Self {
scroll_exits: true,
exit_past_line_start: true,
accept_past_line_end: true,
@@ -443,11 +443,11 @@ impl LogLevel {
/// Convert to a tracing directive string for use with [`EnvFilter`].
pub(crate) fn as_directive(self) -> &'static str {
match self {
- LogLevel::Trace => "trace",
- LogLevel::Debug => "debug",
- LogLevel::Info => "info",
- LogLevel::Warn => "warn",
- LogLevel::Error => "error",
+ Self::Trace => "trace",
+ Self::Debug => "debug",
+ Self::Info => "info",
+ Self::Warn => "warn",
+ Self::Error => "error",
}
}
}
@@ -643,20 +643,20 @@ impl UiColumnType {
/// The Command column returns 0 as it expands to fill remaining space.
pub(crate) fn default_width(self) -> u16 {
match self {
- UiColumnType::Duration => 5, // "814ms"
- UiColumnType::Time => 9, // "459ms ago"
- UiColumnType::Datetime => 16, // "2025-01-22 14:35"
- UiColumnType::Directory => 20,
- UiColumnType::Host => 15,
- UiColumnType::User => 10,
- UiColumnType::Exit => {
+ Self::Duration => 5, // "814ms"
+ Self::Time => 9, // "459ms ago"
+ Self::Datetime => 16, // "2025-01-22 14:35"
+ Self::Directory => 20,
+ Self::Host => 15,
+ Self::User => 10,
+ Self::Exit => {
if cfg!(windows) {
11 // 32-bit integer on Windows: "-1978335212"
} else {
3 // Usually a byte on Unix
}
}
- UiColumnType::Command => 0, // Expands to fill
+ Self::Command => 0, // Expands to fill
}
}
}
@@ -1289,7 +1289,7 @@ impl Settings {
pub(crate) fn new() -> Result<Self> {
let config = Self::build_config()?;
- let settings: Settings = config
+ let settings: Self = config
.try_deserialize()
.map_err(|e| eyre!("failed to deserialize: {}", e))?;