Skip to main content

resq_dsa/
lib.rs

1/*
2 * Copyright 2026 ResQ Software
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//! Production-grade data structures and algorithms — zero external dependencies.
18//!
19//! A collection of space-efficient probabilistic data structures and
20//! graph algorithms for general-purpose use.
21//!
22//! # Modules
23//!
24//! - [`bloom`] - Bloom filter for approximate set membership
25//! - [`count_min`] - Count-Min sketch for frequency estimation
26//! - [`graph`] - Graph algorithms (BFS, Dijkstra, A*)
27//! - [`heap`] - Bounded heap for K-nearest neighbor tracking
28//! - [`trie`] - Trie prefix tree and Rabin-Karp string matching
29//!
30//! # Usage
31//!
32//! ```
33//! use resq_dsa::bloom::BloomFilter;
34//! use resq_dsa::count_min::CountMinSketch;
35//! use resq_dsa::graph::Graph;
36//!
37//! // Bloom filter for deduplication
38//! let mut bf = BloomFilter::new(1000, 0.01);
39//! bf.add("drone-001");
40//! assert!(bf.has("drone-001"));
41//!
42//! // Count-Min for frequency tracking
43//! let mut cms = CountMinSketch::new(0.01, 0.01);
44//! cms.increment("sensor-reading", 5);
45//!
46//! // Graph for pathfinding
47//! let mut g = Graph::<&str>::new();
48//! g.add_edge("base", "waypoint-1", 100);
49//! g.add_edge("waypoint-1", "target", 50);
50//! let (path, cost) = g.dijkstra(&"base", &"target").unwrap();
51//! assert_eq!(path, vec!["base", "waypoint-1", "target"]);
52//! ```
53
54#![cfg_attr(not(feature = "std"), no_std)]
55extern crate alloc;
56
57/// Bloom filter for approximate set membership.
58pub mod bloom;
59/// Count-Min sketch for frequency estimation.
60pub mod count_min;
61/// Graph data structure and pathfinding algorithms.
62///
63/// Requires the `std` feature (enabled by default) because it depends on
64/// `std::collections::{HashMap, HashSet, BinaryHeap, VecDeque}`.
65#[cfg(feature = "std")]
66pub mod graph;
67/// Bounded heap for K-nearest neighbor tracking.
68pub mod heap;
69/// Trie prefix tree and Rabin-Karp pattern matching.
70///
71/// Requires the `std` feature (enabled by default) because it depends on
72/// `std::collections::HashMap`.
73#[cfg(feature = "std")]
74pub mod trie;