Fix clippy warnings: drop needless mut, derive Config's Default
- camera.rs: MmapStream::with_buffers only needs a shared reference to the v4l Device, and the device handle itself was never mutated elsewhere in either capture path, so the mut bindings were dead. - config.rs: Config's manual Default impl just called Default on each field, which #[derive(Default)] already does.
This commit is contained in:
parent
4648fefb8e
commit
ac8a3ccce9
2 changed files with 5 additions and 16 deletions
|
|
@ -98,7 +98,7 @@ pub fn resolve_device(configured: &str, want: DeviceKind) -> Result<PathBuf> {
|
|||
/// Opens the device, captures, and drops it before returning — nothing about this
|
||||
/// camera is left streaming between polls.
|
||||
pub fn grab_rgb_luma(device: &str, width: u32, height: u32) -> Result<GrayFrame> {
|
||||
let mut dev = v4l::Device::with_path(device)
|
||||
let dev = v4l::Device::with_path(device)
|
||||
.with_context(|| format!("opening rgb camera {device}"))?;
|
||||
|
||||
let requested_fourcc = FourCC::new(b"YUYV");
|
||||
|
|
@ -124,7 +124,7 @@ pub fn grab_rgb_luma(device: &str, width: u32, height: u32) -> Result<GrayFrame>
|
|||
);
|
||||
}
|
||||
|
||||
let mut stream = MmapStream::with_buffers(&mut dev, Type::VideoCapture, 2)
|
||||
let mut stream = MmapStream::with_buffers(&dev, Type::VideoCapture, 2)
|
||||
.context("starting rgb capture stream")?;
|
||||
stream.set_timeout(CAPTURE_TIMEOUT);
|
||||
|
||||
|
|
@ -166,7 +166,7 @@ pub fn grab_rgb_luma(device: &str, width: u32, height: u32) -> Result<GrayFrame>
|
|||
/// callers must not hold the IR camera open outside of this function, since that's
|
||||
/// what keeps the IR illuminator from flashing continuously.
|
||||
pub fn grab_ir_burst(device: &str, width: u32, height: u32, count: u32) -> Result<Vec<GrayFrame>> {
|
||||
let mut dev =
|
||||
let dev =
|
||||
v4l::Device::with_path(device).with_context(|| format!("opening ir camera {device}"))?;
|
||||
|
||||
// V4L2 format is persistent device state — without explicitly setting it here,
|
||||
|
|
@ -191,7 +191,7 @@ pub fn grab_ir_burst(device: &str, width: u32, height: u32, count: u32) -> Resul
|
|||
);
|
||||
}
|
||||
|
||||
let mut stream = MmapStream::with_buffers(&mut dev, Type::VideoCapture, 2)
|
||||
let mut stream = MmapStream::with_buffers(&dev, Type::VideoCapture, 2)
|
||||
.context("starting ir capture stream")?;
|
||||
stream.set_timeout(CAPTURE_TIMEOUT);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::path::PathBuf;
|
|||
use anyhow::Result;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[derive(Debug, Clone, Default, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct Config {
|
||||
pub camera: CameraConfig,
|
||||
|
|
@ -148,17 +148,6 @@ impl Default for BreadConfig {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
camera: CameraConfig::default(),
|
||||
motion: MotionConfig::default(),
|
||||
presence: PresenceConfig::default(),
|
||||
bread: BreadConfig::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn load(path: &PathBuf) -> Result<Self> {
|
||||
let cfg = if !path.exists() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue