Skip to content

Commit 3cff541

Browse files
committed
feat: extend api with iterator for routes
Forward iterator access to the routes to allow collecting them as a client. This allows eg. collecting the routes to subscribe them when using the router in an MQTT usecase. Signed-off-by: Marc Bodmer <[email protected]>
1 parent 14dde2b commit 3cff541

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ use alloc::{
142142
string::{String, ToString},
143143
vec::Vec,
144144
};
145-
use core::str::from_utf8;
145+
use core::{slice::Iter, str::from_utf8};
146146
use smallvec::SmallVec;
147147

148148
mod node;
@@ -258,6 +258,10 @@ impl<T> PathTree<T> {
258258
from_utf8(&bytes).map(ToString::to_string).ok()
259259
})
260260
}
261+
262+
pub fn iter(&self) -> Iter<'_, (T, Vec<Piece>)> {
263+
self.routes.iter()
264+
}
261265
}
262266

263267
/// Matched route path infomation.

0 commit comments

Comments
 (0)