Files
ruvnet--RuView/v2/crates/wifi-densepose-core/src/lib.rs
T
rUv 004a63e82d fix(security): audit — fix RUSTSEC vulns, clippy warnings, dead code (#769)
- Upgrade openssl to 0.10.78 (CVE-2026-41676), jsonwebtoken to 9.4
- Suppress unmaintained-only/no-CVE advisories in .cargo/audit.toml
  with per-entry rationale
- Fix all `cargo clippy --all-targets -- -D warnings` errors across
  35 crates: derivable_impls, needless_range_loop, map_or→is_some_and/
  is_none_or, await_holding_lock (drop MutexGuard before .await),
  ptr_arg (&mut Vec→&mut [T]), useless_conversion, approximate_constant
  (2.718→E, 3.14→PI), field_reassign_with_default, manual_inspect,
  useless_vec, lines_filter_map_ok, print_literal, dead_code
- Apply `cargo fmt --all`
- Pre-existing test failure in wifi-densepose-signal
  (test_estimate_occupancy_noise_only) is not introduced by this PR
2026-05-23 05:36:13 -04:00

131 lines
3.6 KiB
Rust

//! # WiFi-DensePose Core
//!
//! Core types, traits, and utilities for the WiFi-DensePose pose estimation system.
//!
//! This crate provides the foundational building blocks used throughout the
//! WiFi-DensePose ecosystem, including:
//!
//! - **Core Data Types**: [`CsiFrame`], [`ProcessedSignal`], [`PoseEstimate`],
//! [`PersonPose`], and [`Keypoint`] for representing `WiFi` CSI data and pose
//! estimation results.
//!
//! - **Error Types**: Comprehensive error handling via the [`error`] module,
//! with specific error types for different subsystems.
//!
//! - **Traits**: Core abstractions like [`SignalProcessor`], [`NeuralInference`],
//! and [`DataStore`] that define the contracts for signal processing, neural
//! network inference, and data persistence.
//!
//! - **Utilities**: Common helper functions and types used across the codebase.
//!
//! ## Feature Flags
//!
//! - `std` (default): Enable standard library support
//! - `serde`: Enable serialization/deserialization via serde
//! - `async`: Enable async trait definitions
//!
//! ## Example
//!
//! ```rust
//! use wifi_densepose_core::{CsiFrame, Keypoint, KeypointType, Confidence};
//!
//! // Create a keypoint with high confidence
//! let keypoint = Keypoint::new(
//! KeypointType::Nose,
//! 0.5,
//! 0.3,
//! Confidence::new(0.95).unwrap(),
//! );
//!
//! assert!(keypoint.is_visible());
//! ```
#![cfg_attr(not(feature = "std"), no_std)]
#![forbid(unsafe_code)]
#[cfg(not(feature = "std"))]
extern crate alloc;
pub mod error;
pub mod traits;
pub mod types;
pub mod utils;
// Re-export commonly used types at the crate root
pub use error::{CoreError, CoreResult, InferenceError, SignalError, StorageError};
pub use traits::{DataStore, NeuralInference, SignalProcessor};
pub use types::{
AntennaConfig,
// Bounding box
BoundingBox,
// Common types
Confidence,
// CSI types
CsiFrame,
CsiMetadata,
DeviceId,
FrameId,
FrequencyBand,
Keypoint,
KeypointType,
PersonPose,
// Pose types
PoseEstimate,
// Signal types
ProcessedSignal,
SignalFeatures,
Timestamp,
};
/// Crate version
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
/// Maximum number of keypoints per person (COCO format)
pub const MAX_KEYPOINTS: usize = 17;
/// Maximum number of subcarriers typically used in `WiFi` CSI
pub const MAX_SUBCARRIERS: usize = 256;
/// Default confidence threshold for keypoint visibility
pub const DEFAULT_CONFIDENCE_THRESHOLD: f32 = 0.5;
/// Prelude module for convenient imports.
///
/// Convenient re-exports of commonly used types and traits.
///
/// ```rust
/// use wifi_densepose_core::prelude::*;
/// ```
pub mod prelude {
pub use crate::error::{CoreError, CoreResult};
pub use crate::traits::{DataStore, NeuralInference, SignalProcessor};
pub use crate::types::{
AntennaConfig, BoundingBox, Confidence, CsiFrame, CsiMetadata, DeviceId, FrameId,
FrequencyBand, Keypoint, KeypointType, PersonPose, PoseEstimate, ProcessedSignal,
SignalFeatures, Timestamp,
};
}
// Compile-time assertions on module-level constants.
const _: () = assert!(MAX_SUBCARRIERS > 0);
const _: () = assert!(DEFAULT_CONFIDENCE_THRESHOLD > 0.0);
const _: () = assert!(DEFAULT_CONFIDENCE_THRESHOLD < 1.0);
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_version_is_valid() {
// CARGO_PKG_VERSION is always non-empty; verify the constant is
// accessible and has a dot-separated semver shape.
assert!(VERSION.contains('.'), "version should be semver: {VERSION}");
}
#[test]
fn test_constants() {
assert_eq!(MAX_KEYPOINTS, 17);
}
}