Struct Node

Source
pub struct Node<T: 'static + Context + Send> {
    pub children: HashMap<String, Node<T>>,
    pub value: String,
    pub is_wildcard: bool,
    pub is_terminal_node: bool,
    /* private fields */
}

Fields§

§children: HashMap<String, Node<T>>§value: String§is_wildcard: bool§is_terminal_node: bool

Implementations§

Source§

impl<T: 'static + Context + Send> Node<T>

Source

pub fn new(value: &str) -> Node<T>

Source

pub fn new_wildcard(param_name: Option<String>) -> Node<T>

Source

pub fn add_route(&mut self, route: &str, middleware: MiddlewareChain<T>)

Source

pub fn add_subtree(&mut self, route: &str, subtree: Node<T>)

Source

pub fn match_route( &self, route: Split<'_, char>, ) -> (HashMap<String, String>, bool, &'_ MiddlewareChain<T>)

Source

pub fn match_route_with_params( &self, route: Split<'_, char>, params: HashMap<String, String>, ) -> (HashMap<String, String>, bool, &'_ MiddlewareChain<T>)

Source

pub fn tree_string(&self, indent: &str) -> String

Used mostly for debugging the route tree Example usage

  let mut app = App::create(generate_context);

  app.get("/plaintext", middleware![plaintext]);
 println!("app: {}", app._route_parser.route_tree.root_node.tree_string(""));
 for (route, middleware) in app._route_parser.route_tree.root_node.get_route_list() {
   println!("{}: {}", route, middleware.len());
 }
Source

pub fn get_route_list( &self, ) -> SmallVec<[(String, MiddlewareChain<T>, bool); 8]>

Source

pub fn push_middleware_to_populated_nodes( &mut self, other_node: &Node<T>, accumulated_middleware: &MiddlewareChain<T>, )

Pushes middleware down to the leaf nodes, accumulating along the way. This is helpful for propagating generic middleware down the stack

Trait Implementations§

Source§

impl<T: Context + Send> Clone for Node<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Node<T>

§

impl<T> !RefUnwindSafe for Node<T>

§

impl<T> Send for Node<T>

§

impl<T> Sync for Node<T>

§

impl<T> Unpin for Node<T>

§

impl<T> !UnwindSafe for Node<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.