agent: lumotia — pin rust toolchain + workspace clippy/fmt sweep
rust-toolchain.toml pins to stable 1.94.1 so contributors and CI runners share the exact rustc / rustfmt / clippy versions. Without the pin, every machine surfaces a different lint set depending on its local install — six pre-existing lints showed up on 1.94.1 that 1.93-era HANDOVER reported clean. Clippy fixes (all pre-existing, not introduced by feature work): - crates/storage/src/database.rs: std::iter::repeat().take() -> repeat_n() - crates/llm/src/lib.rs (docs): "+ frontends" was parsed as a markdown bullet continuation by rustdoc, breaking doc-lazy-continuation. Reworded to "and". - crates/llm/src/lib.rs (loop): while-let-on-iterator -> for-loop. - src-tauri/src/commands/security.rs: .iter().any(|a| *a == x) -> .contains(&x). - src-tauri/src/lib.rs: io::Error::new(Other, e) -> io::Error::other(e). - src-tauri/src/tauri_app_data_migration.rs: drop function-tail `return`s inside cfg blocks; each platform's block now ends with a tail expression. cargo fmt sweep across the workspace. Mechanical layout-only changes; no semantics affected. Workspace gates after this commit: - cargo fmt --check: clean - cargo clippy --workspace --all-targets -- -D warnings: clean - cargo test --workspace: 405/0 (will become 409/0 with Phase A.1+A.2)
This commit is contained in:
@@ -370,7 +370,11 @@ fn open_and_validate(
|
||||
device: cpal::Device,
|
||||
name: &str,
|
||||
require_audio: bool,
|
||||
) -> Result<(MicrophoneCapture, VecDeque<AudioChunk>, mpsc::Receiver<AudioChunk>)> {
|
||||
) -> Result<(
|
||||
MicrophoneCapture,
|
||||
VecDeque<AudioChunk>,
|
||||
mpsc::Receiver<AudioChunk>,
|
||||
)> {
|
||||
let config = device
|
||||
.default_input_config()
|
||||
.map_err(|e| Error::AudioCaptureFailed(format!("default_input_config: {e}")))?;
|
||||
|
||||
@@ -15,7 +15,5 @@ pub async fn decode_and_resample(path: &Path) -> Result<AudioSamples> {
|
||||
resample_to_16khz(&audio)
|
||||
})
|
||||
.await
|
||||
.map_err(|e| {
|
||||
lumotia_core::error::Error::AudioDecodeFailed(format!("Task join error: {e}"))
|
||||
})?
|
||||
.map_err(|e| lumotia_core::error::Error::AudioDecodeFailed(format!("Task join error: {e}")))?
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ pub fn decode_audio_file_limited(
|
||||
path: &Path,
|
||||
max_duration_secs: Option<f64>,
|
||||
) -> Result<AudioSamples> {
|
||||
let file = File::open(path)
|
||||
.map_err(|e| Error::AudioDecodeFailed(format!("Cannot open file: {e}")))?;
|
||||
let file =
|
||||
File::open(path).map_err(|e| Error::AudioDecodeFailed(format!("Cannot open file: {e}")))?;
|
||||
let mss = MediaSourceStream::new(Box::new(file), Default::default());
|
||||
|
||||
let mut hint = Hint::new();
|
||||
@@ -41,8 +41,8 @@ pub fn decode_audio_file_limited(
|
||||
}
|
||||
|
||||
pub fn probe_audio_duration_secs(path: &Path) -> Result<Option<f64>> {
|
||||
let file = File::open(path)
|
||||
.map_err(|e| Error::AudioDecodeFailed(format!("Cannot open file: {e}")))?;
|
||||
let file =
|
||||
File::open(path).map_err(|e| Error::AudioDecodeFailed(format!("Cannot open file: {e}")))?;
|
||||
let mss = MediaSourceStream::new(Box::new(file), Default::default());
|
||||
let mut hint = Hint::new();
|
||||
if let Some(ext) = path.extension().and_then(|e| e.to_str()) {
|
||||
@@ -99,9 +99,7 @@ fn decode_media_stream(
|
||||
.ok_or_else(|| Error::AudioDecodeFailed("Unknown sample rate".into()))?;
|
||||
|
||||
if sample_rate == 0 {
|
||||
return Err(Error::AudioDecodeFailed(
|
||||
"Invalid sample rate: 0".into(),
|
||||
));
|
||||
return Err(Error::AudioDecodeFailed("Invalid sample rate: 0".into()));
|
||||
}
|
||||
|
||||
let track_id = track.id;
|
||||
@@ -128,9 +126,7 @@ fn decode_media_stream(
|
||||
));
|
||||
}
|
||||
Err(e) => {
|
||||
return Err(Error::AudioDecodeFailed(format!(
|
||||
"packet read failed: {e}"
|
||||
)));
|
||||
return Err(Error::AudioDecodeFailed(format!("packet read failed: {e}")));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -168,9 +164,7 @@ fn decode_media_stream(
|
||||
}
|
||||
|
||||
if samples.is_empty() {
|
||||
return Err(Error::AudioDecodeFailed(
|
||||
"No audio data decoded".into(),
|
||||
));
|
||||
return Err(Error::AudioDecodeFailed("No audio data decoded".into()));
|
||||
}
|
||||
|
||||
Ok(AudioSamples::new(samples, sample_rate, 1))
|
||||
|
||||
@@ -77,9 +77,7 @@ impl StreamingResampler {
|
||||
INPUT_CHUNK,
|
||||
1, // mono
|
||||
)
|
||||
.map_err(|e| {
|
||||
Error::AudioDecodeFailed(format!("StreamingResampler init failed: {e}"))
|
||||
})?;
|
||||
.map_err(|e| Error::AudioDecodeFailed(format!("StreamingResampler init failed: {e}")))?;
|
||||
|
||||
Ok(Self::Sinc {
|
||||
resampler,
|
||||
@@ -110,9 +108,7 @@ impl StreamingResampler {
|
||||
let chunk: Vec<f32> = residual.drain(..INPUT_CHUNK).collect();
|
||||
let input = vec![chunk];
|
||||
let result = resampler.process(&input, None).map_err(|e| {
|
||||
Error::AudioDecodeFailed(format!(
|
||||
"StreamingResampler process failed: {e}"
|
||||
))
|
||||
Error::AudioDecodeFailed(format!("StreamingResampler process failed: {e}"))
|
||||
})?;
|
||||
if let Some(channel) = result.into_iter().next() {
|
||||
out.extend_from_slice(&channel);
|
||||
@@ -144,9 +140,7 @@ impl StreamingResampler {
|
||||
|
||||
let input = vec![chunk];
|
||||
let result = resampler.process(&input, None).map_err(|e| {
|
||||
Error::AudioDecodeFailed(format!(
|
||||
"StreamingResampler flush failed: {e}"
|
||||
))
|
||||
Error::AudioDecodeFailed(format!("StreamingResampler flush failed: {e}"))
|
||||
})?;
|
||||
|
||||
let Some(mut out) = result.into_iter().next() else {
|
||||
|
||||
@@ -42,9 +42,8 @@ impl WavWriter {
|
||||
};
|
||||
let file = std::fs::File::create(path).map_err(Error::from)?;
|
||||
let buffered = BufWriter::new(file);
|
||||
let inner = hound::WavWriter::new(buffered, spec).map_err(|e| {
|
||||
Error::from(std::io::Error::other(format!("WAV create failed: {e}")))
|
||||
})?;
|
||||
let inner = hound::WavWriter::new(buffered, spec)
|
||||
.map_err(|e| Error::from(std::io::Error::other(format!("WAV create failed: {e}"))))?;
|
||||
Ok(Self {
|
||||
inner,
|
||||
samples_since_flush: 0,
|
||||
@@ -77,9 +76,9 @@ impl WavWriter {
|
||||
/// `Self::DEFAULT_FLUSH_EVERY_SAMPLES` — but may do so at natural
|
||||
/// boundaries (end-of-utterance, UI events) for tighter recovery.
|
||||
pub fn flush(&mut self) -> Result<()> {
|
||||
self.inner.flush().map_err(|e| {
|
||||
Error::from(std::io::Error::other(format!("WAV flush failed: {e}")))
|
||||
})?;
|
||||
self.inner
|
||||
.flush()
|
||||
.map_err(|e| Error::from(std::io::Error::other(format!("WAV flush failed: {e}"))))?;
|
||||
self.samples_since_flush = 0;
|
||||
Ok(())
|
||||
}
|
||||
@@ -89,9 +88,9 @@ impl WavWriter {
|
||||
/// writer leaves a playable file up to the last flush; callers
|
||||
/// that care about the unflushed tail should always finalise.
|
||||
pub fn finalize(self) -> Result<()> {
|
||||
self.inner.finalize().map_err(|e| {
|
||||
Error::from(std::io::Error::other(format!("WAV finalize failed: {e}")))
|
||||
})?;
|
||||
self.inner
|
||||
.finalize()
|
||||
.map_err(|e| Error::from(std::io::Error::other(format!("WAV finalize failed: {e}"))))?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -105,21 +104,20 @@ pub fn write_wav(path: &Path, audio: &AudioSamples) -> Result<()> {
|
||||
sample_format: hound::SampleFormat::Int,
|
||||
};
|
||||
|
||||
let mut writer = hound::WavWriter::create(path, spec).map_err(|e| {
|
||||
Error::from(std::io::Error::other(format!("WAV create failed: {e}")))
|
||||
})?;
|
||||
let mut writer = hound::WavWriter::create(path, spec)
|
||||
.map_err(|e| Error::from(std::io::Error::other(format!("WAV create failed: {e}"))))?;
|
||||
|
||||
for &sample in audio.samples() {
|
||||
let clamped = sample.clamp(-1.0, 1.0);
|
||||
let int_sample = (clamped * i16::MAX as f32) as i16;
|
||||
writer.write_sample(int_sample).map_err(|e| {
|
||||
Error::from(std::io::Error::other(format!("WAV write failed: {e}")))
|
||||
})?;
|
||||
writer
|
||||
.write_sample(int_sample)
|
||||
.map_err(|e| Error::from(std::io::Error::other(format!("WAV write failed: {e}"))))?;
|
||||
}
|
||||
|
||||
writer.finalize().map_err(|e| {
|
||||
Error::from(std::io::Error::other(format!("WAV finalize failed: {e}")))
|
||||
})?;
|
||||
writer
|
||||
.finalize()
|
||||
.map_err(|e| Error::from(std::io::Error::other(format!("WAV finalize failed: {e}"))))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -146,17 +144,14 @@ pub fn read_wav(path: &Path) -> Result<AudioSamples> {
|
||||
.map(|sample| {
|
||||
sample
|
||||
.map(|s| s as f32 / (1 << (bits_per_sample - 1)) as f32)
|
||||
.map_err(|e| {
|
||||
Error::AudioDecodeFailed(format!("WAV sample decode failed: {e}"))
|
||||
})
|
||||
.map_err(|e| Error::AudioDecodeFailed(format!("WAV sample decode failed: {e}")))
|
||||
})
|
||||
.collect::<Result<Vec<f32>>>()?,
|
||||
hound::SampleFormat::Float => reader
|
||||
.into_samples::<f32>()
|
||||
.map(|sample| {
|
||||
sample.map_err(|e| {
|
||||
Error::AudioDecodeFailed(format!("WAV sample decode failed: {e}"))
|
||||
})
|
||||
sample
|
||||
.map_err(|e| Error::AudioDecodeFailed(format!("WAV sample decode failed: {e}")))
|
||||
})
|
||||
.collect::<Result<Vec<f32>>>()?,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user