Skip to content

Commit

Permalink
feat: extend api with iterator for routes
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
mbodmer committed Jun 6, 2024
1 parent 14dde2b commit 3cff541
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ use alloc::{
string::{String, ToString},
vec::Vec,
};
use core::str::from_utf8;
use core::{slice::Iter, str::from_utf8};
use smallvec::SmallVec;

mod node;
Expand Down Expand Up @@ -258,6 +258,10 @@ impl<T> PathTree<T> {
from_utf8(&bytes).map(ToString::to_string).ok()
})
}

pub fn iter(&self) -> Iter<'_, (T, Vec<Piece>)> {
self.routes.iter()
}
}

/// Matched route path infomation.
Expand Down

0 comments on commit 3cff541

Please sign in to comment.