[−][src]Struct gotham::router::tree::node::Node
A recursive member of Tree
, representative of segment(s) in a request path.
Each node includes 0..n
Route
instances, which can be further evaluated by the Router
based on a match. Every node may also have 0..n
children to provide the recursive tree
representation.
Methods
impl Node
[src]
pub fn new(segment: &str, segment_type: SegmentType) -> Self
[src]
Creates new Node
for the given segment and type.
pub fn add_child(&mut self, node: Node) -> &mut Self
[src]
Adds a new child Node
instance to this Node
.
pub fn add_route(
&mut self,
route: Box<dyn Route<ResBody = Body> + Send + Sync>
) -> &mut Self
[src]
&mut self,
route: Box<dyn Route<ResBody = Body> + Send + Sync>
) -> &mut Self
Adds a Route
to this Node
, to be potentially evaluated by the Router
.
pub fn borrow_child(
&self,
segment: &str,
segment_type: SegmentType
) -> Option<&Node>
[src]
&self,
segment: &str,
segment_type: SegmentType
) -> Option<&Node>
Borrows a child Node
based on the defined segment bounds.
pub fn borrow_child_mut(
&mut self,
segment: &str,
segment_type: SegmentType
) -> Option<&mut Node>
[src]
&mut self,
segment: &str,
segment_type: SegmentType
) -> Option<&mut Node>
Borrows a mutable child Node
based on the defined segment bounds.
pub fn has_child(&self, segment: &str, segment_type: SegmentType) -> bool
[src]
Determines if a child exists based on the defined segment bounds.
pub fn is_routable(&self) -> bool
[src]
Determines if this Node
has any valid Route
values attached.
pub fn match_node<'a>(
&'a self,
segments: &'a [PercentDecoded]
) -> Option<(&'a Node, SegmentMapping<'a>, usize)>
[src]
&'a self,
segments: &'a [PercentDecoded]
) -> Option<(&'a Node, SegmentMapping<'a>, usize)>
Traverses this Node
and its children, attempting to a locate a path of Node
instances
which match all segments of the provided Request
path. The final Node
must have at
least a single Route
attached in order to be returned.
Only the first matching path is returned from this method, and the value is wrapped in
an Option
as there may be no matching node.
Children are searched in a most to least specific order of segments, based on the node
SegmentType
value:
- Static
- Constrained
- Dynamic
- Glob
This method is a wrapping of an internal recursive implementation to mask the required types needed for the recursion.
pub fn segment<'a>(&'a self) -> &'a str
[src]
Retrieves a reference to the contained segment value.
This is required for lifetime related annotations.
pub fn select_route(
&self,
state: &State
) -> Result<&Box<dyn Route<ResBody = Body> + Send + Sync>, RouteNonMatch>
[src]
&self,
state: &State
) -> Result<&Box<dyn Route<ResBody = Body> + Send + Sync>, RouteNonMatch>
Determines if a Route
instance associated with this Node
is willing to Handle
the
request.
Where multiple Route
instances could possibly handle the Request
only the first, ordered
per creation, is invoked.
Where no Route
instances will accept the Request
the resulting Error will be the
union of the RouteNonMatch
values returned from each Route
.
In the situation where all these avenues are exhausted an InternalServerError will be provided.
Trait Implementations
impl PartialEq<Node> for Node
[src]
fn eq(&self, other: &Node) -> bool
[src]
Compares two Node
values for equality based on the segments they represent.
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialOrd<Node> for Node
[src]
fn partial_cmp(&self, other: &Node) -> Option<Ordering>
[src]
Compares two Node
values to determine an appropriate Ordering
.
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Eq for Node
[src]
impl Ord for Node
[src]
fn cmp(&self, other: &Node) -> Ordering
[src]
Compares two Node
values to determine an appropriate Ordering
.
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
[src]
clamp
)Restrict a value to a certain interval. Read more
Auto Trait Implementations
impl Unpin for Node
impl Sync for Node
impl Send for Node
impl RefUnwindSafe for Node
impl !UnwindSafe for Node
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,