Struct Sorted Registry
Generated from cargo doc --no-deps -p nemo-relay-builtins -p nemo-relay-diagnostics -p nemo-relay-logging -p nemo-relay-plugin-host -p nemo-relay-codecs -p nemo-relay -p nemo-relay-runtime -p nemo-relay-model-pricing -p nemo-relay-resource-metrics -p nemo-relay-observability -p nemo-relay-adaptive -p nemo-relay-pii-redaction -p nemo-relay-ffi -p nemo-relay-types -p nemo-relay-plugin -p nemo-relay-worker-proto -p nemo-relay-worker.
pub struct SortedRegistry<T: RegistryEntry> { /* private fields */ }
A named registry that maintains a sorted order by priority.
Items are stored by their embedded RegistryEntry::name value and sorted by RegistryEntry::priority. The sort is performed eagerly: every register or deregister call re-sorts immediately, so sorted_values is a read-only lookup.
Clones share immutable storage. A successful mutation copies shared storage, leaving snapshots unchanged; failed mutations keep sharing the original storage.
Priority ordering
Entries are sorted in ascending priority order (lower numbers run first). This means a guardrail with priority 1 executes before one with priority 10.
Uniqueness
Names must be unique within a registry. Attempting to register a duplicate name returns an error. Use deregister first to remove an existing entry before re-registering.
Implementations
impl<T: RegistryEntry> SortedRegistry<T>
impl<T: RegistryEntry> SortedRegistry<T>
new
pub fn new() -> Self
Create a new empty registry.
Returns
A new empty SortedRegistry with no entries.
register
pub fn register(&mut self, entry: T) -> Result<(), String>where
T: Clone,
Register a new entry under its embedded name.
Parameters
entry: Value to store in the registry.
Returns
Ok(()) when the entry was inserted.
Errors
Returns Err(String) when name is already present in the registry.
Notes
Successful registration eagerly re-sorts the cached priority order.
deregister
pub fn deregister(&mut self, name: &str) -> boolwhere
T: Clone,
Deregister an entry by name.
Parameters
name: Name of the entry to remove.
Returns
true when an entry was removed and false when name was not present.
Notes
Successful removal eagerly re-sorts the cached priority order.
sorted_values
pub fn sorted_values(&self) -> impl Iterator<Item = &T>
Return entries sorted by priority (ascending).
This is a read-only operation - the sort order is maintained eagerly on every register / deregister call.
Returns
Shared references ordered from lowest priority to highest priority, without allocating an intermediate collection.
is_empty
pub fn is_empty(&self) -> bool
Whether this registry contains no entries, without scanning retained storage.
values
pub fn values(&self) -> impl Iterator<Item = &T>
Return every entry without imposing priority order.
Trait Implementations
impl<T: Clone + RegistryEntry> Clone for SortedRegistry<T>
impl<T: Clone + RegistryEntry> Clone for SortedRegistry<T>
clone
fn clone(&self) -> SortedRegistry<T>
clone_from
fn clone_from(&mut self, source: &Self)
impl<T: RegistryEntry> Default for SortedRegistry<T>
impl<T: RegistryEntry> Default for SortedRegistry<T>
default
fn default() -> Self