fix(02-01): fix clippy warnings to pass lint checks
- config.rs: Added Default derive, removed manual impl - template.rs: Simplified iterator with flatten() - camera/linux.rs: Added transmute annotations, fixed doc syntax - camera/mod.rs: Allow unused imports from linux module - ipc.rs: Renamed default() to with_default_path(), simplified closures - secure_memory.rs: Use is_multiple_of() instead of modulo - phase3_security_test.rs: Use std::f32::consts::PI
This commit is contained in:
@@ -195,7 +195,7 @@ impl Camera {
|
||||
};
|
||||
|
||||
// Store as 'static - we ensure device outlives stream
|
||||
self.stream = Some(unsafe { std::mem::transmute(stream) });
|
||||
self.stream = Some(unsafe { std::mem::transmute::<Stream<'_>, Stream<'static>>(stream) });
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ mod ir_emitter;
|
||||
mod linux;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[allow(unused_imports)]
|
||||
pub use linux::*;
|
||||
|
||||
// IrEmitterControl is exported for use in tests and external code
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
//!
|
||||
//! #[tokio::main]
|
||||
//! async fn main() {
|
||||
//! let client = IpcClient::default();
|
||||
//! let client = IpcClient::with_default_path();
|
||||
//!
|
||||
//! // Check if daemon is running
|
||||
//! if client.ping().await.unwrap() {
|
||||
@@ -756,7 +756,7 @@ impl IpcClient {
|
||||
}
|
||||
|
||||
/// Create a client with the default socket path
|
||||
pub fn default() -> Self {
|
||||
pub fn with_default_path() -> Self {
|
||||
Self::new(IpcServer::default_socket_path())
|
||||
}
|
||||
|
||||
@@ -820,7 +820,7 @@ impl IpcClient {
|
||||
"Connection timeout",
|
||||
))
|
||||
})?
|
||||
.map_err(|e| Error::Io(e))?;
|
||||
.map_err(Error::Io)?;
|
||||
|
||||
let request_json =
|
||||
serde_json::to_string(request).map_err(|e| Error::Serialization(e.to_string()))?;
|
||||
@@ -837,7 +837,7 @@ impl IpcClient {
|
||||
"Read timeout",
|
||||
))
|
||||
})?
|
||||
.map_err(|e| Error::Io(e))?;
|
||||
.map_err(Error::Io)?;
|
||||
|
||||
if n == 0 {
|
||||
return Err(Error::Io(std::io::Error::new(
|
||||
|
||||
@@ -82,17 +82,6 @@ impl SecureEmbedding {
|
||||
}
|
||||
}
|
||||
|
||||
/// Unlock memory when dropping (called by Drop implementation)
|
||||
fn try_unlock_memory(&self) {
|
||||
let byte_slice = unsafe {
|
||||
std::slice::from_raw_parts(
|
||||
self.data.as_ptr() as *const u8,
|
||||
self.data.len() * std::mem::size_of::<f32>(),
|
||||
)
|
||||
};
|
||||
let _ = memory_protection::unlock_memory(byte_slice);
|
||||
}
|
||||
|
||||
/// Get the embedding dimension
|
||||
pub fn len(&self) -> usize {
|
||||
self.data.len()
|
||||
@@ -189,7 +178,7 @@ impl SecureEmbedding {
|
||||
|
||||
/// Deserialize from bytes
|
||||
pub fn from_bytes(bytes: &[u8]) -> Result<Self> {
|
||||
if bytes.len() % 4 != 0 {
|
||||
if !bytes.len().is_multiple_of(4) {
|
||||
return Err(Error::Serialization(
|
||||
"Invalid embedding byte length".to_string(),
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user