Skip to content

Commit 1577de0

Browse files
committed
Document implementation details
1 parent bd111f6 commit 1577de0

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ fn main() -> Result<(), Box<dyn Error>> {
139139
}
140140
```
141141

142-
```
142+
```text
143143
/
144144
├─ backups/
145145
│ ╰─ <*path>
@@ -161,6 +161,21 @@ fn main() -> Result<(), Box<dyn Error>> {
161161
╰─ /message
162162
```
163163

164+
## Implementation details
165+
166+
`wayfind` uses a compressed radix trie for its data storage.
167+
This is the common backbone of almost all routers implemented in Rust.
168+
169+
What sets `wayfind` apart is its search strategy.
170+
Most routers either use "first match wins" or "best match wins" (via backtracking), `wayfind` uses a hybrid approach:
171+
172+
- per segment: first match wins
173+
- within segment: best match wins
174+
175+
You only pay the cost of backtracking if you make use of inline parameters, and only for that given segment.
176+
177+
This can result in some matches which may be unexpected, but in practice it works well for real-world usage.
178+
164179
## Performance
165180

166181
`wayfind` is fast, and appears to be competitive against other top performers in all benchmarks we currently run.

src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,12 @@
136136
//! See [`Errors`](errors) for examples.
137137
138138
#![no_std]
139-
140139
extern crate alloc;
141140

141+
#[cfg(doctest)]
142+
#[doc = include_str!("../README.md")]
143+
mod readme_doctests {}
144+
142145
pub mod errors;
143146

144147
mod node;

0 commit comments

Comments
 (0)