Skip to content

Commit

Permalink
improve commandline utility
Browse files Browse the repository at this point in the history
  • Loading branch information
mcroomp committed Nov 22, 2024
1 parent e0559a2 commit 260e1df
Show file tree
Hide file tree
Showing 7 changed files with 472 additions and 217 deletions.
81 changes: 44 additions & 37 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ simple_logger ="5.0"
unroll = "0.1"
rayon-core = { version = "1", optional = true }
git-version = "0.3"
pico-args = "0.5"

[target.'cfg(windows)'.dependencies]
cpu-time = "1.0"
Expand Down
9 changes: 9 additions & 0 deletions src/lepton_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ impl From<TryFromIntError> for LeptonError {
}
}

impl From<pico_args::Error> for LeptonError {
#[track_caller]
fn from(e: pico_args::Error) -> Self {
let mut e = LeptonError::new(ExitCode::SyntaxError, e.to_string().as_str());
e.add_context();
e
}
}

impl<T> From<std::sync::mpsc::SendError<T>> for LeptonError {
#[track_caller]
fn from(e: std::sync::mpsc::SendError<T>) -> Self {
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ pub use metrics::Metrics;

use crate::lepton_error::{AddContext, Result};

#[cfg(not(feature = "use_rayon"))]
pub fn set_thread_priority(priority: thread_priority::ThreadPriority) {
thread_priority::set_current_thread_priority(priority).unwrap();
crate::structs::simple_threadpool::set_thread_priority(priority);
}

/// Decodes Lepton container and recreates the original JPEG file
pub fn decode_lepton<R: BufRead, W: Write>(
reader: &mut R,
Expand Down
Loading

0 comments on commit 260e1df

Please sign in to comment.