Skip to main content

TrieNode

Struct TrieNode 

Source
pub struct TrieNode<V> { /* private fields */ }
Expand description

Implementation of a trie tree structure. In Sozu this is used to store and lookup domains recursively. Each node represents a “level domain”. A leaf node (leftmost label) can be a wildcard, a regex pattern or a plain string. Leaves also store a value associated with the complete domain. For Sozu it is a list of (PathRule, MethodRule, ClusterId). See the Router strucure.

Implementations§

Source§

impl<V: Debug + Clone> TrieNode<V>

Source

pub fn new(key: Key, value: V) -> TrieNode<V>

Source

pub fn wildcard(key: Key, value: V) -> TrieNode<V>

Source

pub fn root() -> TrieNode<V>

Source

pub fn is_empty(&self) -> bool

Source

pub fn insert(&mut self, key: Key, value: V) -> InsertResult

Source

pub fn insert_recursive( &mut self, partial_key: &[u8], key: &Key, value: V, ) -> InsertResult

Source

pub fn remove(&mut self, key: &Key) -> RemoveResult

Source

pub fn remove_recursive(&mut self, partial_key: &[u8]) -> RemoveResult

Source

pub fn lookup_with_path<'a, 'b>( &'b self, partial_key: &'a [u8], accept_wildcard: bool, trace: TrieMatches<'a, 'b>, ) -> Option<(&'b KeyValue<Key, V>, TrieMatches<'a, 'b>)>

Look up partial_key and additionally collect the non-literal segments that matched along the way (TrieMatches).

Equivalent to lookup for callers that don’t need the captures, but frontends with $HOST[n] rewrite templates need the matched segments to fill the placeholders. The accumulator is passed in by value so callers can pre-size it (Vec::with_capacity) and we own the path returned alongside the value.

Source

pub fn lookup( &self, partial_key: &[u8], accept_wildcard: bool, ) -> Option<&KeyValue<Key, V>>

Source

pub fn lookup_mut( &mut self, partial_key: &[u8], accept_wildcard: bool, ) -> Option<&mut KeyValue<Key, V>>

Source

pub fn print(&self)

Source

pub fn print_recursive(&self, partial_key: &[u8], indent: u8)

Source

pub fn for_each_value_mut<F: FnMut(&mut V)>(&mut self, f: &mut F)

Visit every stored value in the trie (the literal key_value and the leftmost wildcard slot of every node, plus all regex-subtree leaves) and invoke f on each. Used by the router to walk all routes for cross-cutting refreshes (e.g. listener- default HSTS reflow) without rebuilding the trie.

Source

pub fn domain_insert(&mut self, key: Key, value: V) -> InsertResult

Source

pub fn domain_remove(&mut self, key: &Key) -> RemoveResult

Source

pub fn domain_lookup( &self, key: &[u8], accept_wildcard: bool, ) -> Option<&KeyValue<Key, V>>

Source

pub fn domain_lookup_mut( &mut self, key: &[u8], accept_wildcard: bool, ) -> Option<&mut KeyValue<Key, V>>

Source

pub fn size(&self) -> usize

Source

pub fn to_hashmap(&self) -> HashMap<Key, V>

Source

pub fn to_hashmap_recursive(&self, h: &mut HashMap<Key, V>)

Trait Implementations§

Source§

impl<V: Debug> Debug for TrieNode<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: Default> Default for TrieNode<V>

Source§

fn default() -> TrieNode<V>

Returns the “default value” for a type. Read more
Source§

impl<V: PartialEq> PartialEq for TrieNode<V>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<V> Freeze for TrieNode<V>
where V: Freeze,

§

impl<V> RefUnwindSafe for TrieNode<V>
where V: RefUnwindSafe,

§

impl<V> Send for TrieNode<V>
where V: Send,

§

impl<V> Sync for TrieNode<V>
where V: Sync,

§

impl<V> Unpin for TrieNode<V>
where V: Unpin,

§

impl<V> UnsafeUnpin for TrieNode<V>
where V: UnsafeUnpin,

§

impl<V> UnwindSafe for TrieNode<V>
where V: UnwindSafe,

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more